把标记放在国家 [英] Put marker on country
问题描述
geocoding
,它表示我达到了允许对我的名字进行地理编码的请求限制。所以没有一个完整的客户端方式做到这一点,而不接触服务器的国家坐标? 可以创建一个包含您想要的国家和他们的坐标的kml文件,然后在您的地图代码中使用这个。
$ b
var map = new google .maps.Map(document.getElementById(map_canvas),0ptions);
var kmzLayer = new google.maps.KmlLayer('http://yoursite/countries.kmz');
kmzLayer.setMap(map);
您可以将标记添加到kml文件中作为在这个例子中, a>
另一种选择是将你的国家和地理编码存储在json中,然后遍历json添加标记。
Stackoverflow问题
看看这个例子,它允许你点击显示一个国家和国家的名称和国旗。
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?
You can create a kml file with the countries you want and their coordinates and then consume this in your map code.
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.
这篇关于把标记放在国家的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!