-1

I am trying get all coordinates of India. I have tried with http://maps.google.com/maps/api/geocode/json?sensor=true&address=India.

In this i am getting only bounds of southEast, northWest.

But i need complete list of all coordinates which will exactly match india polygon.

I have tried with twitter API. But its giving rectangular area coordinates of the country like below.

enter image description here

I need exact polygon coordinates. Any suggestion?

Eswara Reddy
  • 1,617
  • 1
  • 18
  • 28
  • Have a look at http://stackoverflow.com/questions/12194046/google-maps-api-v3-how-to-get-region-border-coordinates-polyline-data – myxobek Oct 08 '15 at 09:07
  • @myxobek I have tried with Twitter API. In that i am getting 5 coordinates only. Tried with this https://api.twitter.com/1.1/geo/search.json?granularity=country&query=india. But i need all coordinates. – Eswara Reddy Oct 08 '15 at 09:27
  • its giving exact rectangle shape coordinates. Actually i need polygon coordinates not rectangle. – Eswara Reddy Oct 08 '15 at 10:05
  • It looks like the polygon is still available in the twitter v1.1 api: https://dev.twitter.com/rest/reference/get/geo/id/%3Aplace_id – geocodezip Oct 08 '15 at 13:13
  • @geocodezip Check for this https://api.twitter.com/1.1/geo/id/b850c1bfd38f30e0.json?place_id=b850c1bfd38f30e0 I am getting only 5 coordinates. – Eswara Reddy Oct 09 '15 at 12:53
  • `{"errors":[{"code":215,"message":"Bad Authentication data."}]}` – geocodezip Oct 09 '15 at 13:09
  • @geocodezip Yep. You cannot check above mentioned URL directly. For that use twitter dev console.(https://dev.twitter.com/) – Eswara Reddy Oct 10 '15 at 13:41
  • Don't have one of those. – geocodezip Oct 10 '15 at 13:42
  • @geocodezip Sorry check this in https://dev.twitter.com/rest/tools/console with GET method, OAuth authentication and URL as https://api.twitter.com/1.1/geo/id/b850c1bfd38f30e0.json?place_id=b850c1bfd38f30e0 – Eswara Reddy Oct 10 '15 at 13:53

1 Answers1

0

You can make use of natural earth data fusion table for countries. It's public table & downloadable. Here is a demo. I used a temp API key in demo which I'll remove after some time.

HTML:

<html>
<head>
<title>Google Maps API v3 : Fusion Tables Layer</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
</script>
</head>
<body onload="initialize()">
<div id="map" style="width: 530px; height:230px">
</div>
    <div id="datadiv"></div>
</body>
</html>

Javascript:

function initialize()
{
    map = new google.maps.Map(document.getElementById('map'),
    {
        center: new google.maps.LatLng(22.7964,79.5410),
        zoom: 4,
        mapTypeId: 'roadmap'
    });

    layer = new google.maps.FusionTablesLayer({query: {
      select: '\'wkt_4326\'',
      from: '1uKyspg-HkChMIntZ0N376lMpRzduIjr85UYPpQ',
      where:'sov_a3=\'IND\''

    }});
    debugger
    layer.setMap(map);
    getData('1uKyspg-HkChMIntZ0N376lMpRzduIjr85UYPpQ');
}


function getData(table) {
    // Builds a Fusion Tables SQL query and hands the result to dataHandler()

    var queryUrl = 'https://www.googleapis.com/fusiontables/v1/query?sql=';
    var queryUrlParams = '&key=GET_YOUR_API_KEY_FROM_GOOGLE&jsonCallback=?'; // ? could be a function name

    var query = "SELECT * FROM " + table + " where sov_a3='IND'";
    var queryurl = encodeURI(queryUrl + query + queryUrlParams);
    //Get fusion table data
    $.get(queryurl,showData);
}

function showData(d) {
    debugger
    var data = d.rows[0];
    $("#datadiv").html(data);
}
SSA
  • 5,433
  • 4
  • 36
  • 50