4

I need to have a map with a list of markers on it. It needs to transition between these smoothly.

I have the following code which currently loops around the markers.

var x = 0;
function pan_to() {

    if(x >= addresses.length){
        x=0;
    }
    $.getJSON('http://maps.googleapis.com/maps/api/geocode/json?address='+addresses[x]+'&sensor=false', null, function (data) {
        var p = data.results[0].geometry.location
        var latlng = new google.maps.LatLng(p.lat, p.lng);

        map.panTo(latlng);

    });
    x++;

} setInterval(pan_to,3000);

Working example here - http://jsfiddle.net/shanejones/khX2K/

What I need is the map to smoothly transition for 1 seconds between them with some form of easing too. Anyone have any ideas

Shane Jones
  • 885
  • 1
  • 9
  • 27
  • 2
    Why was this downvoted? Its a perfectly valid question. +1 – pattyd Jul 02 '14 at 16:28
  • 2
    Pretty much why I rarely come here now... :( – Shane Jones Jul 02 '14 at 16:31
  • Just noticed your Jsfiddle doesn't show a result, maybe fixing that would be a good idea? ;) – pattyd Jul 02 '14 at 16:33
  • Sorted. The MapsAPI dropped out the fiddle settings for some reason. – Shane Jones Jul 02 '14 at 16:35
  • 1
    [working fiddle](http://jsfiddle.net/khX2K/2/) (at least shows the map, the API wasn't included). Update, just saw your response, you have to make sure to do an "update" after making any changes or they go away. – geocodezip Jul 02 '14 at 16:37
  • You have missing semicolons on lines 15 and 31... try using the JShint tool in JSfiddle and it will display errors in your code :) – pattyd Jul 02 '14 at 16:39
  • possibly relevant question [Google Maps v3 - can I ensure smooth panning every time?](http://stackoverflow.com/questions/3817812/google-maps-v3-can-i-ensure-smooth-panning-every-time) – geocodezip Jul 02 '14 at 16:41

0 Answers0