google-mapsgoogle-maps-markersblink

How to Google Maps marker blink for time interval?


I am new at Google Maps technologies.I want to blink or bounce google maps marker for a time interval for example one minute.Is it possible to do it? Could you please show me a way to succeed it?


Solution

  • may cause errors. (using googlemap without apikey)

    var on = true;
    var intervalSeconds = 0.5;
    var myLatLng = {lat: -25.363, lng: 131.044};
    
    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 4,
      center: myLatLng
    });
    
    var marker = new google.maps.Marker({
      position: myLatLng,
      map: map,
      title: 'Hello World!'
    });
    
    setInterval(function() {
       if(on) {
         marker.setMap(null);
       } else {
         marker.setMap(map);
       }
      on = !on;
    }, intervalSeconds * 1000);
    #map {
        width: 800px;
        height: 600px;
      }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <div id="map"></div>