Question

I have a script that generates a ton of locations/places based on a users input. I want to add these places as markers on Google Maps based on javascript APIv3, but I would easily go over the geocoding limit.

Is there a way simply to insert a string of a popular location into the markers options variable and have it load on the map? So insert "Boston, USA" instead of latlng(X,Y)? Are their other options available to me? I know of free geocoding APIs, but not all my locations are in the US.

Was it helpful?

Solution

The only way to specify a Marker's location in Google Maps JavaScript API v3 is with a LatLng object. You cannot specify the Marker's location with a common name like "Boston, USA".

One thing you may want to consider is how a map will perform with lots of Markers. (I'm assuming by "a ton" you mean at least 500.) That might heavily tax your user's computer/device and the user may end up with little more than a blob of markers that's less than completely useful. Perhaps you can test with, say, 1000 markers on a less-than-kickass machine and see how your code performs. You may find that you need to rethink your interface in a way that reduces the number of markers you use anyway.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top