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

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

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?