Is there anyway so I can get boundries of countries in polygon coordinates value using Google map API.
How do I show borders on Google Maps? Just click on the Country's,state,city or even neighborhood name and the borders will be highlighted!
Note that the Maps Embed API, Maps SDK for Android, and Maps SDK for iOS currently have no usage limits and are at no charge (usage of the API or SDKs is not applied against your $200 monthly credit).
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?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
<table>
<tr>
<td>
<div id="map_canvas" style="height:200px; width:300px;"></div>
</td>
<td>
<div id="info"></div>
</td>
</tr>
</table>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With