本文介绍了如何更改谷歌地图中的标记图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有20个标记,我想用相似的标记和相似的标记(A)显示10个标记,其他10个标记我想用不同的标记图像和不同的标记(B)显示。即时获得所有标记相同的图像和相同的标签
js fiddle
var initMap = function(){
var labels ='0123456789';
var labelIndex = 0;
var myLatLng = {lat:17.446507,lng:78.383033,deviceId:'a'};
var citymap = {
hyderabad:{
center:{lat:17.446507,lng:78.383033},
population:5000
}
};
var map = new google.maps.Map(document.getElementById('map'),{
zoom:18,
center:myLatLng,
});
}
解决方案
var marker = new google.maps.Marker({
position:location,
icon:condition?image_1:image_2,
map:map
});
您可以提及您希望image_1作为标记的条件。
i have 20 markers from which i want to show 10 markers with similar marker and with similar label ("A") , and other 10 i want to show with different marker image and different label ("B") . im getting all the marker with same image and same label
js fiddlehttps://jsfiddle.net/9yq8y1p2/4/
var initMap = function () {
var labels = '0123456789';
var labelIndex = 0;
var myLatLng = { lat: 17.446507, lng: 78.383033, deviceId: 'a' };
var citymap = {
hyderabad: {
center: { lat: 17.446507, lng: 78.383033 },
population: 5000
}
};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 18,
center: myLatLng,
});
}
解决方案
var marker = new google.maps.Marker({
position: location,
icon: condition ? image_1 :image_2,
map: map
});
You can mention the condition for which you want image_1 as marker.
这篇关于如何更改谷歌地图中的标记图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!