2
votes

Is there a way to add a map marker with the Google Maps JS SDK without using coordinates (i.e. using a full address instead)?

I know this is possible with the static image API: http://maps.googleapis.com/maps/api/staticmap?center=501+Diplomat+Parkway+Hallandale+Beach+33009+United+States&zoom=14&size=240x240&maptype=roadmap&markers=color:green%7C501+Diplomat+Parkway+Hallandale+Beach+33009+United+States&sensor=false

Unfortunately I need more interactivity so the static image API isn't enough.

The documentation refers to only Lat/Long: https://developers.google.com/maps/documentation/javascript/reference#MarkerOptions

I tried to set it as an address string, but didn't work.

So far my only choice seems to be that I use geocoding API. I hope this is not the only choice.

1

1 Answers

2
votes

Sorry but I think there is no option or web service from Google to directly add a marker by passing an address. For the moment, you have to retrieve the lat/lng of your address and then add your marker...

Maybe you could directly use the following code :

var geocoder = new GClientGeocoder();

var address = "Your address";
geocoder.getLatLng(address, function(point) {
         var latitude = point.y;
         var longitude = point.x;  

         // use here the lat/lng values to add your marker        
});

Hope this helps ! Bye !