Reputation: 5
I am pulling is lat long points from a database, combine them, then use reverse lookup to place markers on my map. All the markers get placed on the map, but they are just a little off. I then go to maps.google.com and place the points into the search bar and they work perfectly. Any suggestions? Thank you! The funciton is below:
var lat = resultP[i].get("lat");
var log = resultP[i].get("long");
var latlng = new google.maps.LatLng(lat, log);
geocoder.geocode( { 'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
} //end else
Upvotes: 0
Views: 233
Reputation: 364
Apologies if I misunderstood something, but I don't see why you need to geocode the coordinates.
Geocoding is the process of turning an address into coordinates, or the other way around. You don't need to geocode your coordinates if you already have them. The whole point of geocoding is to put them on the nearest road.
To display a marker on the map you can just skip the geocoding and do this:
var lat = resultP[i].get("lat");
var log = resultP[i].get("long");
var latlng = new google.maps.LatLng(lat, log);
var marker = new google.maps.Marker({
map: map,
position: latlng
});
Upvotes: 1