php - 获取数组 OpenStreetMap API Json 失败
问题描述
我是编程新手。
我正在尝试从 JSON 数据中获取坐标位置。这是我的脚本:
$jsonurl = "http://photon.komoot.de/api/?q=kemang+timur+jakarta&limit=1";
$json = file_get_contents($jsonurl,0,null,null);
$json_output = json_decode($json, true);
echo $json_output['features'][0]['type']['geometry']['coordinates'];
但是,它失败了。我只是收到错误消息。
警告:第 12 行 C:\xampp\htdocs\mios\open\lokasi.php 中的非法字符串偏移“几何”警告:C:\xampp\htdocs\mios\open\lokasi.php 中的非法字符串偏移“坐标”线 12 F
如果我在这里打印 JSON 数据
Array ( [features] => Array ( [0] => Array ( [geometry] => Array ( [coordinates] => Array ( [0] => 106.8230188 [1] => -6.2631289 ) [type] => Point ) [type] => Feature [properties] => Array ( [osm_id] => 31779962 [osm_type] => W [extent] => Array ( [0] => 106.8220505 [1] => -6.2624677 [2] => 106.823754 [3] => -6.263854 ) [country] => Indonesia [osm_key] => highway [city] => Jakarta Special Capital Region [osm_value] => residential [postcode] => 12730 [name] => Jalan Kemang Timur VI ) ) ) [type] => FeatureCollection )
解决方案
推荐阅读
- simpledateformat - java使用simpledateformat解析一个输入String得到ParseException,而仅仅因为一个空格
- .net-core - 将 FluentValidation 与 ASP.NET Core 3.1 和视图组件集成
- testing - 在 Test Cafe 上设置 Firefox 的推荐人
- docker - 在 VS 代码中调试 docker 映像:找不到 cs 文件:
- django - 如何在MongoDB中使用Django Relational DB的ForeignKey、ManyToManyFields等字段
- scala - 使用 apache spark 和 scala 将数据推送到 Nifi Flow
- javascript - 使用 Chart.js 时隐藏 xAxis 标签
- python - 如何在python数据透视表数据框中的条形图中添加数据标签值
- python - 为什么隐藏对 dash_html_components.Label 不起作用?
- pandas - Groupby 两列的总和并在熊猫中创建新的数据框