dqeonr8554 2013-12-21 16:49
浏览 91
已采纳

php使用xml文件中的纬度和经度获取谷歌地图pano_id [重复]

This question already has an answer here:

I want to get street view pano_id using latitude and longitude. I met to get that from this link. http://cbk0.google.com/cbk?output=xml&ll=40.714103,-74.006206

It returns xml output and I want to get that pano_id from it. If can get A,B and C all pano_ids really appreciate that.

<panorama>
  <data_properties image_width="13312" image_height="6656" tile_width="512" tile_height="512" image_date="2012-08" pano_id="dIT1qZK8wyNVROwryyiN8g" imagery_type="1" num_zoom_levels="3" lat="40.714131" lng="-74.006188" original_lat="40.714096" original_lng="-74.006246" elevation_wgs84_m="-19.853310" best_view_direction_deg="120">
    <copyright>© 2013 Google</copyright>
    <text>Chambers Street</text>
    <street_range>66</street_range>
    <region>New York</region>
    <country>United States</country>
  </data_properties>
  <projection_properties projection_type="spherical" pano_yaw_deg="130.9" tilt_yaw_deg="-82.94" tilt_pitch_deg="1.15"/>
  <annotation_properties>
    <link yaw_deg="123.44" pano_id="l-oSyXcA8I9emj2IVGslvw" road_argb="0x80fffa73" scene="0">
      <link_text>Chambers Street</link_text>
    </link>
    <link yaw_deg="302.91" pano_id="TKBUYV2jeHoA7HTwX5bx7A" road_argb="0x80fffa73" scene="0">
      <link_text>Broadway / Chambers Street</link_text>
    </link>
  </annotation_properties>
</panorama>

enter image description here

</div>
  • 写回答

1条回答 默认 最新

  • dpgu5074 2013-12-21 17:08
    关注

    You want to use PHP's SimpleXML.

    <?php
    
    $xml = new SimpleXMLElement(file_get_contents('http://cbk0.google.com/cbk?output=xml&ll=40.714103,-74.006206'));
    
    foreach ($xml->data_properties as $element) {
        echo $element->attributes()->pano_id . "<br/>";
    }
    
    foreach ($xml->annotation_properties->link as $element) {
        echo $element->attributes()->pano_id . "<br/>";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改