本文介绍了使用Google Map API v3的国家边界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 反正有,所以我可以使用Google map API获取多边形坐标值的国家边界。 问题: Google地图V3:绘制德国州多边形? FusionTables中的自然地球数据集具有可用的国家多边形。你可以根据自己的喜好来设计风格。 我用它来创建这个例子: http://www.geocodezip.com/v3_FusionTablesLayer_worldmap_linkto.html 下面是一个使用KmlLayer的示例: 代码段: var kmlLayer = null; var map = null; function openIW(layerEvt){if(layerEvt.row){var content = layerEvt.row ['admin'] .value; } else if(layerEvt.featureData){var content = layerEvt.featureData.name; } document.getElementById('info')。innerHTML =你点击了:< br> + content;} function initialize(){var chicago = new google.maps.LatLng(36.4278,-15.9); var myOptions = {zoom:0,center:chicago,mapTypeId:google.maps.MapTypeId.ROADMAP} map = new google.maps.Map(document.getElementById(map_canvas),myOptions); google.maps.event.addListener(map,click,function(){document.getElementById('info')。innerHTML =;}); kmlLayer = new google.maps.KmlLayer('http://www.geocodezip.com/geoxml3_test/world_countries_kml.xml',{preserveViewport:true,suppressInfoWindows:true}); kmlLayer.setMap(地图); google.maps.event.addListener(kmlLayer,'click',openIW);} google.maps.event.addDomListener(window,'load',initialize); < script src =https://maps.googleapis.com/maps/api/js>< /脚本><表> < TR> < TD> < div id =map_canvasstyle =height:200px; width:300px;>< / div> < / TD> < TD> < div id =info>< / div> < / TD> < / table> Is there anyway so I can get boundries of countries in polygon coordinates value using Google map API. 解决方案 See this similar question:Google Maps V3: Draw German State Polygons?The Natural Earth Data Set in FusionTables has country polygons available in it. You can style them as you like.I used it to create this example:http://www.geocodezip.com/v3_FusionTablesLayer_worldmap_linkto.htmlHere is an example that uses a KmlLayer:http://www.geocodezip.com/v3_GoogleEx_layer-kml_world_countries_simple.htmlcode snippet:var kmlLayer = null;var map = null;function openIW(layerEvt) { if (layerEvt.row) { var content = layerEvt.row['admin'].value; } else if (layerEvt.featureData) { var content = layerEvt.featureData.name; } document.getElementById('info').innerHTML = "you clicked on:<br>" + content;}function initialize() { var chicago = new google.maps.LatLng(36.4278, -15.9); var myOptions = { zoom: 0, center: chicago, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); google.maps.event.addListener(map, "click", function() { document.getElementById('info').innerHTML = ""; }); kmlLayer = new google.maps.KmlLayer('http://www.geocodezip.com/geoxml3_test/world_countries_kml.xml', { preserveViewport: true, suppressInfoWindows: true }); kmlLayer.setMap(map); google.maps.event.addListener(kmlLayer, 'click', openIW);}google.maps.event.addDomListener(window, 'load', initialize);<script src="https://maps.googleapis.com/maps/api/js"></script><table> <tr> <td> <div id="map_canvas" style="height:200px; width:300px;"></div> </td> <td> <div id="info"></div> </td> </tr></table> 这篇关于使用Google Map API v3的国家边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-03 19:45