我已经创建了基本的地理围栏,我在该地图中添加了2个标记和一个圆圈。我试图显示标记是否出现在圆圈标记上应该以不同的颜色显示,以便我们可以了解物体是否出于地理围栏。如何改变标记的颜色或在标记超出圆圈时显示不同的标记.LatLng1不在圆形中,因此我需要将Latlng1显示在圆外。如何在谷歌地图与c做地理围栏#
爵士小提琴链接
代码
function toggleBounce() {
alert("Asset 1");
if (marker.getAnimation() !== null) {
marker.setAnimation(null);
} else {
marker.setAnimation(google.maps.Animation.BOUNCE);
}
}
function initMap() {
var myLatLng = { lat:17.446399, lng:78.383349};
var myLatLng1 = { lat: 17.428888, lng: 78.384444 };
var citymap = {
hyderabad: {
center: { lat: 17.446507, lng: 78.383033 },
population: 2714856
}
};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 18,
center: myLatLng,
});
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 14,
center: myLatLng1
});
var image = "https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png";
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: 'Asset 1',
animation: google.maps.Animation.DROP,
});
marker.addListener('click', toggleBounce);
var marker = new google.maps.Marker({
position: myLatLng1,
map: map,
title: 'Hello World!',
icon:image
});
for (var city in citymap) {
// Add the circle for this city to the map.
var cityCircle = new google.maps.Circle({
strokeColor: '#ffb3b3',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#ffb3b3',
fillOpacity: 0.35,
map: map,
center: citymap[city].center,
radius: Math.sqrt(citymap[city].population) * 1
});
}
}