【问题标题】:How to get all coordinates of single country or state rather than only bounds?如何获取单个国家或州的所有坐标而不​​仅仅是边界?
【发布时间】:2015-10-08 09:01:03
【问题描述】:

我正在尝试获取印度的所有坐标。我试过http://maps.google.com/maps/api/geocode/json?sensor=true&address=India

在这我只得到东南西北的界限。

但我需要与印度多边形完全匹配的所有坐标的完整列表。

我已经尝试过使用 twitter API。但它给出了国家的矩形区域坐标,如下所示。

我需要精确的多边形坐标。有什么建议吗?

【问题讨论】:

标签: php google-maps laravel-4 geolocation google-geocoding-api


【解决方案1】:

您可以为国家/地区使用natural earth data 融合表。它是公共表和可下载的。这是demo。我在演示中使用了一个临时 API 密钥,我会在一段时间后将其删除。

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 我在javascript中不需要这个。我想要这个在 PHP 中。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-05-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-12-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多