【发布时间】:2017-11-03 06:39:22
【问题描述】:
我正在使用 Overpass Turbo 在地图上显示信息。 我的部分代码(我用的是PHP)如下:
//overpass query
$overpass = 'http://overpass-api.de/api/interpreter?data=[out:json];area(3600046663)->.searchArea;(node["amenity"="drinking_water"](area.searchArea););out;';
// collecting results in JSON format
$html = file_get_contents($overpass);
$jsonout = json_decode($html);
// this line just checks what the query would give as output
var_dump($jsonout);
JSON 格式的查询结果(var_dump 显示的内容)如下所示:
version: 0.6
generator: "Overpass API"
osm3s:
timestamp_osm_base: "2017-11-03T06:25:02Z"
timestamp_areas_base: "2017-11-03T05:45:02Z"
copyright: "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL."
elements:
0:
type: "node"
id: 254917402
lat: 46.0672187
lon: 11.1379545
tags:
amenity: "drinking_water"
1:
type: "node"
id: 257481472
lat: 46.0687113
lon: 11.1201097
tags:
amenity: "drinking_water"
等等。
您可以自己查看,在浏览器中复制/粘贴查询网址:http://overpass-api.de/api/interpreter?data=[out:json];area(3600046663)-%3E.searchArea;(node[%22amenity%22=%22drinking_water%22](area.searchArea););out;
如您所见,上述数组中的每个element 都有latitude 和longitude 信息。我需要那些在地图上显示标记。
我无法从数组中的每个元素中分离出lat 和lon 信息。我该怎么做?
【问题讨论】:
标签: php json api leaflet output