谷歌地图状态下拉菜单



有没有办法用谷歌地图获得国家的下拉菜单?我有兴趣让地图以下拉状态为中心,有点像这样:http://www.dyngeometry.com/web/WorldRegion.aspx

谢谢!

您可以预先填充州列表(如果您需要多个国家/地区和其他行政级别,则为国家/地区及其相应的层次结构)。使用 Google 地图地理编码 API 获取边界框,并使用返回的状态的位置将其居中。

所以对于加利福尼亚来说,它看起来像这样:

请求:https://maps.googleapis.com/maps/api/geocode/json?address=CA&key=your_key_here

响应:

{  
   results:[  
      {  
         address_components:[  
            {  
               long_name:"California",
               short_name:"CA",
               types:[  
                  "administrative_area_level_1",
                  "political"
               ]
            },
            {  
               long_name:"United States",
               short_name:"US",
               types:[  
                  "country",
                  "political"
               ]
            }
         ],
         formatted_address:"California, USA",
         geometry:{  
            bounds:{  
               northeast:{  
                  lat:42.0095169,
                  lng:-114.1313927
               },
               southwest:{  
                  lat:32.5342622,
                  lng:-124.415165
               }
            },
            location:{  
               lat:36.778261,
               lng:-119.4179324
            },
            location_type:"APPROXIMATE",
            viewport:{  
               northeast:{  
                  lat:42.0095169,
                  lng:-114.1313927
               },
               southwest:{  
                  lat:32.5342622,
                  lng:-124.415165
               }
            }
         },
         place_id:"ChIJPV4oX_65j4ARVW8IJ6IJUYs",
         types:[  
            "administrative_area_level_1",
            "political"
         ]
      }
   ],
   status:"OK"
}

最新更新