0

私はこれに2日間取り組んでいますが、何が起こっているのかわかりません。

Google Maps farmácia loc の住所の近くで薬局を探しています: R. Manoel Bandeira, 324-490, Embu - São Paulo, 06846-570, Brazil

ご覧のとおり、5 km 以内に薬局がたくさんあります。

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>
4

0 に答える 0