2016-05-13 94 views
0

我使用谷歌地圖圖書館豐富的標誌,現在我要調整標記大小縮放時我有這樣的事情,但我改變背景顏色進行了測試,但似乎不工作:是否可以通過縮放更改Rich標記大小?

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); 
     } 

這是我的第二個選項,這也不起作用:

locations[i][0].Normalsize = new google.maps.Size(20, 20); 

,這是位置數組:

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'}], 

,並在這裏,我本身噸一個標記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 
     }); 

回答

0

得到了解決對不起自己開個問題迅速!:

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'}); 
    } 
相關問題