问题
I have a bunch of country names. Like hundreds. I want to add a marker on each of the countries that I have. If I use geocoding
it says I reach the limit of requests allowed to geocode my names. So isn't there an entire "client way" of doing this without contacting the server for coordinates of the country?
回答1:
You can create a kml file with the countries you want and their coordinates and then consume this in your map code.
KML howto
var map = new google.maps.Map(document.getElementById("map_canvas"), 0ptions);
var kmzLayer = new google.maps.KmlLayer('http://yoursite/countries.kmz');
kmzLayer.setMap(map);
You can add the markers to the kml file as in this example
Another option would be to store your countries and geocodes in json and then iterate over the json to add the markers.
Stackoverflow question Take a look at this example which allows you to click on a country and the country name and flag are shown.
来源:https://stackoverflow.com/questions/11154353/put-marker-on-country