谷歌地方API和谷歌地图网站之间的结果是不一样的

时间:2013-06-25 15:58:34

标签: google-maps google-places-api

我正在研究这个问题2天,我不知道发生了什么。

我在Google地图上的地址附近寻找Phamacy farmácialoc:R. Manoel Bandeira,324-490,Embu - SãoPaulo,06846-570,Brazil

正如您所看到的,5公里附近有很多药店

尝试使用google places api在我的网站上进行此操作时。结果是=没有。 遵循代码 有什么想法吗?

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false&language=se"></script>
<script>

function init() {

const location=new google.maps.LatLng(-23.6334282, -46.8739405);
const radius = 5000;

// Make map
var mapOptions = {
center: location,
zoom: 11,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map'), mapOptions);

// Make a circle
var circOptions={
center: location,
radius: radius,
map: map
};
circle = new google.maps.Circle(circOptions);  

// Get shops in radius
service = new google.maps.places.PlacesService(map);
var request={                                               //my request
location: location,
radius: radius,
types: ["pharmacy"]
};

service.search(request, function (results, status){
if (status == google.maps.places.PlacesServiceStatus.OK){
for (var i= 0, result; result=results[i]; i++) {     //add markers
distance=google.maps.geometry.spherical.computeDistanceBetween(location, result.geometry.location);
if (distance>radius)
continue;

var marker = new google.maps.Marker({
map: map,
position: result.geometry.location,
reference: result.reference
});
}
}
});

}
google.maps.event.addDomListener(window, 'load', init);

</script>

<style>#map {height: 500px;width: 500px;}</style>
</head>
<body><div id="map"></div></body>
</html>

0 个答案:

没有答案