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/>";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?