使用Google Map API v3的国家边界 [英] Country boundries using Google Map API v3
问题描述
反正有,所以我可以使用Google map API获取多边形坐标值的国家边界。
FusionTables中的自然地球数据集具有可用的国家多边形。你可以根据自己的喜好来设计风格。
我用它来创建这个例子:
http://www.geocodezip.com/v3_FusionTablesLayer_worldmap_linkto.html
代码段:
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);
< pre class =snippet-code-html lang-html prettyprint-override> < 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.html
Here is an example that uses a KmlLayer: http://www.geocodezip.com/v3_GoogleEx_layer-kml_world_countries_simple.html
code 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的国家边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!