2012-03-16 52 views
3

我有在地圖上如何使標記圖像在谷歌地圖閃爍

的代碼部分的一些指標是這裏

var icons=["media/green.png","media/red.png","media/blue.png","media/yellow.png"]; 

var marker = new google.maps.Marker({ 
      position: new google.maps.LatLng(100*array_lat[j],100*array_lon[j]), 
      map  : map, 
      url  : "javascript:setNavtrack('DISPLAYDATA')", 
      icon : icons[i] 
      }); 

我的心願,我想閃爍的「媒體/紅巴紐」圖標

任何解決方案?

+3

閃爍標誌?這是什麼,1997? – Blazemonger 2012-03-16 16:43:19

+0

mblase給出了一個解決方案.. – Vibing 2012-03-19 08:50:23

+0

我無法忍受自己爲了讓互聯網更加醜陋而積分。 – Blazemonger 2012-03-19 13:02:29

回答

3

你可以試着改變媒體/ red.png的 「閃爍」 媒體/ red.gif,如果它不工作,改變marker.optimized爲false:(從.gif marker google maps答案代碼)

var marker = new google.maps.Marker({ 
    position: latLng, 
    map: map, 
    icon: iconoMarca, 
    optimized: false 
    }); 

要看起來像:

var icons=["media/green.png","media/red.gif","media/blue.png","media/yellow.png"]; 
var marker = new google.maps.Marker({ 
      position: new google.maps.LatLng(100*array_lat[j],100*array_lon[j]), 
      map  : map, 
      url  : "javascript:setNavtrack('DISPLAYDATA')", 
      icon : icons[i], 
      optimized:false 
      }); 
+0

已優化:false僅適用於GIF動畫。 – Vibing 2012-03-16 16:28:53

+0

多數民衆贊成在計劃,您的「動畫」gif是閃爍的標記 – demve 2012-03-17 15:32:58

0

使用閃爍的動畫gif。

+0

給出一個鏈接到動畫標記..... – Vibing 2012-03-16 16:24:46

+0

您可以使用imagemagick變形之間的標記和空圖像:http://www.imagemagick.org /用法/ anim_mods /#morph – devsnd 2012-03-16 16:40:27

+0

如何獲取空圖像? – Vibing 2012-03-19 08:48:21

1
var marker = new google.maps.Marker({ 
     map: map, 
     position: mapOptions.center 
    }); 

    interval = setInterval(function() { toggleMarker() }, 500); 

    function toggleMarker() { 
     if (marker.getVisible()) { 
     marker.setVisible(false); 
     } else { 
     marker.setVisible(true); 
     } 
    } 
+0

不能正常工作.... – Vibing 2012-03-19 08:48:55

0

我是不是能夠得到GIF動畫看起來不錯,所以我想在此基礎上演示對「Localmind」的YouTube不同的方法。結果很不錯。 以下是我用來使其工作的代碼部分。請注意,我正在使用一些包裝和實用程序,因此您必須做一些翻譯或刪除部分。

// setup the selection state that is needed 
var circle, 
    intervalWaitCount = 10, 
    startingStrokeWeight = 1, 
    circleOptions = { 
     radius: 0, // in meters 
     strokeOpacity: 1, 
     strokeColor: red, 
     strokeWeight: startingStrokeWeight, 
     fillOpacity: 0, 
     map: map, 
     center: marker.position 
    }; 
// remove from the last selected 
if (components.MapWrapper.lastSelectedMarker) { 
    components.MapWrapper.lastSelectedMarker.circle.setVisible(false); 
    window.clearInterval(components.MapWrapper.lastSelectedMarker.interval); 
} 
if (marker.circle) { 
    marker.circle.setVisible(!marker.circle.getVisible()); 
    circle = marker.circle; 
} else { 
    circle = new google.maps.Circle(circleOptions); 
    marker.circle = circle; 
} 
marker.interval = window.setInterval(function() { 
    if (intervalWaitCount > 5) { 
     intervalWaitCount--; 
     return; 
    } 
    var radius = circle.getRadius(); 
    circleOptions.strokeColor = green; // choose a color, I was changing based on a condition 
    circleOptions.center = marker.position; 
    if (radius <= 50000) { 
     circleOptions.strokeWeight = circleOptions.strokeWeight - 0.1; 
     circleOptions.radius = radius + 10000; 
     circle.setOptions(circleOptions); 
     // don't wait 
     intervalWaitCount = 0; 
    } else { 
     circleOptions.radius = 0; 
     circle.setOptions(circleOptions); 
     circleOptions.strokeWeight = startingStrokeWeight; 
     // wait five cycles before restarting the animation 
     intervalWaitCount = 10; 
    } 
}, 100); 
components.MapWrapper.lastSelectedMarker = marker;