2

I know that you can put a marker on a long/lat coordinate, but I am having a hard time finding where/how you can place a marker on a specific street address. Can anyone tell me how to do this? I am using V3 of the API and JQuery.

3 Answers 3

2

Right, basically query the maps API by address through a call to Geocoder. It should return to you a LAT/LNG which then you can use to create a marker.

function mygeocoder(addr){
  var geocoder = new google.maps.Geocoder();

    if (geocoder) {
      geocoder.geocode({ 'address': addr }, function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
          console.log("LAT: ", results[0].geometry.location.lat());
          console.log("LNG: ", results[0].geometry.location.lng());
        }
    else {
       console.log("Geocoding failed: " + status);
    }
      });
   }
 }
Sign up to request clarification or add additional context in comments.

Comments

1

You will need to run a geocoding query.

View this source for details: http://code.google.com/apis/maps/documentation/javascript/examples/geocoding-simple.html

Comments

0

@James has pointed out how to run a geocoding request, but you can take advantage of a jQuery plugin like landcarte to make it shorter and clearer like that:

var map = $("#map").geoMap();
map.search("Copenhagen", function(data) {
  if (data.location) map.add("marker", data.location);
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.