在Google地图中查找最近的学校以获取邮政编码

时间:2012-03-29 06:55:27

标签: google-maps google-maps-api-3

如何在最近的学校搜索任何给定的邮政编码,如下面的屏幕截图所示?

http://i.imgur.com/xjrMp.png

当我访问maps.google.com时,我没有看到此选项。或者只能通过Google Maps API使用?我怎么能这样做?

2 个答案:

答案 0 :(得分:2)

Places API会执行类似的操作。请参阅https://google-developers.appspot.com/maps/documentation/javascript/examples/place-search上的示例并更改代码,将"store"更改为"school"(如有必要,将location更改为其他内容。

您引用的示例可能有自己的学校数据库。

答案 1 :(得分:1)

安德鲁完全正确。您需要与地图一起拨打电话。

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places"></script>

基本设置:

 var customMapType = new google.maps.StyledMapType(featureOpts, styledMapOptions);
  map.mapTypes.set(MY_MAPTYPE_ID, customMapType); 
  // Places request
  // ALL TYPES: https://developers.google.com/places/documentation/supported_types
  var request = {
    location: myLatLng,
    radius: 500,
    types: ['school']
  };

此示例在投入使用时需要进行一些修改。

我最近必须为我的一个项目做这件事(对于这个例子中令人讨厌的多边形感到抱歉),这里是jsFiddle