احصل على معلمة من عنصر مشدود في خرائط Google
-
29-09-2019 - |
سؤال
سابقا أنا إحصل على جواب بربط عنصر. سؤالي التالي هو: كيف يمكنني الحصول على معلمة "نصف القطر" لدائرة مشتعلة ، من العلامة؟
الرمز:
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);
أحتاج إلى نصف قطر Cirlce ، الذي يرتدي علامة الصفيف [X]. اي فكرة؟ شكرا مقدما!
المحلول
لا أعتقد أن هناك طريقة للحصول على كائن ملزم من كائن.
ما يمكنك فعله هو ضبط الدائرة ككائن على العلامة
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);
الآن يمكنك الحصول على نصف القطر
Array[x].circle.getRadius();
لا تنتمي إلى StackOverflow