Obtenez un paramètre d'un élément binded dans Google Maps
-
29-09-2019 - |
Question
Auparavant, je obtenir une réponse à la mise en relation de un élément. Ma question suivante est: comment puis-je obtenir le paramètre « rayon » d'un cercle binded, du marqueur
Le code:
var marker = new google.maps.Marker({
position: new google.maps.LatLng(lat,lng),
});
var circle = new google.maps.Circle({
map: map,
radius: 50,
});
circle.bindTo('map', marker);
circle.bindTo('center', marker, 'position');
Array.push(marker);
J'ai besoin de rayon de la cirlce, qui binded au tableau marqueur [x]. Une idée? Merci à l'avance!
La solution
Je ne pense pas qu'il y ait un moyen d'obtenir un objet lié d'un objet.
Qu'est-ce que vous pouvez sur le marqueur faire est de définir le cercle comme un objet
var marker = new google.maps.Marker({
position: new google.maps.LatLng(lat,lng),
});
var circle = new google.maps.Circle({
map: map,
radius: 50,
});
marker.circle = circle; // Add the circle object to the map object
circle.bindTo('map', marker);
circle.bindTo('center', marker, 'position');
Array.push(marker);
Maintenant vous pouvez obtenir le rayon avec
Array[x].circle.getRadius();
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow