ds2321 2011-10-15 15:39
浏览 11
已采纳

在html中使用Google地图APi

I had used Google MAP with android before but now I want to use it with in my webpage.My idea is that I have a webpage in which there is a textfield .When I will enter America in it then It must show me the Satellite view of America.I had not used any Google Map with HTML before.One idea is to use Php curl with it,Can anyone tell me how i can do this?

  • 写回答

2条回答 默认 最新

  • drqja5919276 2011-10-15 15:56
    关注

    If you send a geocoding request to Google's Geocoder, for example for "USA":

    http://maps.googleapis.com/maps/api/geocode/json?address=USA&sensor=false
    

    you will get an JSON result. Part of that result will be the viewport:

     "viewport" : {
               "northeast" : {
                  "lat" : 64.73664149999999,
                  "lng" : -30.14648320
               },
               "southwest" : {
                  "lat" : -5.70344770,
                  "lng" : -161.27929880
               }
            }
    

    also available as XML:

     http://maps.googleapis.com/maps/api/geocode/json?address=USA&sensor=false
    

    these are the boundaries of a rectangle that covers the entire area of the USA.

    Using these coordinates, you can then proceed to the "normal" Google Maps API examples and have the map show exactly that bounding box.

    Use the fitBounds parameter in the Map's constructor. fitBounds is an object of the type LatLngBounds that you need to construct out of the viewport's coordinates.

    It's not entirely trivial to do, but definitely possible. You can use PHP to make the first XML request, then output the JavaScript to generate the map.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统