Monday, April 25, 2011

can someone explain this code in detail and how should i run it in my javascript program

javascript: 

(function () 
{
  if (!map.me)
  {
    map.me = map.createLocationMarker(
      "http://libgmail.sourceforge.net/man.png", N.get("local"));
  };
  mv = function(i) 
  {
    c = map.directions.polyline.getPoint(i);
    map.recenterOrPanToLatLng(c);
    map.setMarkerPosition(map.me, N.get("local"), c); 
    if (i < map.directions.polyline.numPoints - 1)
    {
       window.setTimeout("mv("+(i+1) + ")",750)
    }
    else
    {
      map.me.hide()
    }
  };
  map.me.show();
  mv(0)
}
)();

what is i and what is c, i want to use this code in my javascript so that i can move my mam icon along a route, how can i do it

From stackoverflow
  • c is a co-ordinate and i is an indexer, both are coming from the outer scope to which this code belongs.

  • c - point in the map i - integer parameter of function, that means number of point, starts with 0, every recursion loop increments by 1, ends by map.directions.polyline.numPoints - 1

    This code shows the way across all points in map.directions.polyline

0 comments:

Post a Comment