[英]Is it possible to change Rich marker size by zoom?
I am using the library Rich marker for google maps, now I want to resize the marker size while zooming I have something like this but i tested it with changing the bg color but is seems not to work: 我正在使用库Rich标记用于Google地图,现在我想在缩放时调整标记大小,但是我有这样的东西,但是我通过更改bg颜色对其进行了测试,但似乎无法正常工作:
locations[i][0].Smallsize = $('.rich-marker').css({ 'width' : '5px', 'height' : '5px' });
locations[i][0].Normalsize = $('.rich-marker').css('background-color', 'red' );
if (map.getZoom() === 16) {
marker.scaledSize = locations[i][0].Smallsize;
console.log(marker.scaledSize);
}
if (map.getZoom() === 17) {
marker.scaledSize = locations[i][0].Normalsize;
console.log(marker.scaledSize);
}
This is my second option which also doesn't work: 这是我的第二个选项,它也不起作用:
locations[i][0].Normalsize = new google.maps.Size(20, 20);
and this is the array of locations: 这是位置的数组:
var locations = [
[{id: 1, lat: 51.523903408094064, lng: 5.137792649612493, content: 'Kids Jungalow Giraffe'}],
[{id: 2, lat: 51.52377991387855, lng: 5.137905302391118, content: 'Kids Jungalow Giraffe'}],
[{id: 3, lat: 51.523643068545915, lng: 5.138098421440191, content: 'Kids Jungalow Giraffe'}],
[{id: 4, lat: 51.52347284572886, lng: 5.1382003453827565, content: 'Kids Jungalow Giraffe'}],
[{id: 5, lat: 51.52331931087756, lng: 5.1383505490875905, content: 'Kids Jungalow Giraffe'}],
and here i set the marker in a for loop: 在这里,我将标记设置为for循环:
for (i = 0; i < locations.length; i++) {
var myLatLng = new google.maps.LatLng({lat: locations[i][0].lat, lng: locations[i][0].lng});
var number = locations[i][0].id;
var marker_html = '<div class="rich-marker">'+'<span class="number-id">' + number + '</span>' + '</div>';
var marker = new RichMarker({
position: myLatLng,
scaledSize: new google.maps.Size(15, 15),
draggable: true,
map: map,
flat: true,
anchor: RichMarkerPosition.MIDDLE,
content: marker_html
});
Got the solution myself sorry for opening a question to quickly!: 我自己得到了解决方案,抱歉为您快速提出问题!:
if (map.getZoom() === 16) {
$('.rich-marker').css({ 'width' : '5px', 'height' : '5px' });
$('.number-id').css({ 'font-size' : '5px'});
}
if (map.getZoom() === 17) {
$('.rich-marker').css({ 'width' : '16px', 'height' : '16px' });
$('.number-id').css({ 'font-size' : '8px'});
}
if (map.getZoom() === 18) {
$('.rich-marker').css({ 'width' : '20px', 'height' : '20px' });
$('.number-id').css({ 'font-size' : '12px'});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.