使用Google Geocoder API的邮政编码半径搜索

问题描述 投票:1回答:1

Here is a link to the same question.

但是,我想使用Google Geocode回答这个问题。有人可以使用Meteor和Blaze为我提供执行以下操作的代码。

  1. 输入邮政编码,并返回距离该邮政编码10公里以内的邮政编码数组。
  2. 在集合用户中搜索profile.zipcode字段,并在阵列中显示与邮政编码匹配的用户。

非常感谢!

meteor google-geocoding-api geocode
1个回答
0
投票

The Geocoder从文本字符串获取您的位置,现在您必须将此位置信息传递给您的位置功能。我已经将Google Places代码包装在一个函数中,并从geocoder对其进行了调用。

var address = '12 Crest View Ct';

geocoder.geocode({'address': address},
    function(results, status) {
        if(status == google.maps.GeocoderStatus.OK){
        loc = results[0].geometry.location;

            var bounds = new google.maps.LatLngBounds();
            document.write(bounds.extend(results[0].geometry.location));
            map.fitBounds(bounds);
            new google.maps.Marker({
                position:results[0].geometry.location,
                map: map
            });
        place(loc); //here is the function call
        }

    }
);
© www.soinside.com 2019 - 2024. All rights reserved.