Hi Ross,

  I've contacted google for a premier Licence.

  I've tryed to implement this in a way which gDirection.load is
separated by X seconds (from 3 to 10) same issue.

  One direction is displayed correctly, two doesn't works. error 602

The code... is quite complicated.

I use Extjs. The direction data (from, to are stored in a grid)


On the grid, i've set a on render function  :

 listeners :{render:function(){
          window.setTimeout(function(){
            MonitorOutputDispositifCs.prototype.displayRoute(0);
          },1000);

        }},


MonitorOutputDispositifCs.prototype.displayRoute=function(startIndex)
{

  var map           = Ext.getCmp('center-carte-paris-panel');
  var directions    = map.getDirectionsCat('lieu_cat_9');
  var oneDirectionSet  = null;
  //find the next non null directionSet
  while(oneDirectionSet == null && startIndex < directions.length)
  {
    oneDirectionSet  = directions[startIndex++];
  }

  if(oneDirectionSet == null)
    return;

  alert(startIndex+'
'+oneDirectionSet.directionInfo.routeInstruction);
  if(oneDirectionSet.directionInfo.displayed== false)
  {
//display the direction
 
oneDirectionSet.gDirection.load( oneDirectionSet.directionInfo.routeInstruction,
{ "locale": 'fr' , "getSteps":true});
    oneDirectionSet.directionInfo.displayed=true;
//launch the render of the next direction in X seconds
    window.setTimeout( function(){
      MonitorOutputDispositifCs.prototype.displayRoute(startIndex);
      }
      ,10000);
  }
  else
    MonitorOutputDispositifCs.prototype.displayRoute(startIndex);
};

var directions is filled by this function  :

  /**
   * directionInfo.fromAddress
   * directionInfo.toAddress
   * directionInfo.category
   * directionInfo.businessId
   * directionInfo.title,
   * directionInfo.html,
   * directionInfo.routeInstruction,
   * directionInfo.displayed
   * */
  displayRouteForDispositif:function(directionInfo)
  {
    if(this.googleMapAvailable!= true)
      return;
    //create cat if not exist
    if(!this.directionCategories[directionInfo.category])
      this.directionCategories[directionInfo.category]=[];

    var directionCat =
this.directionCategories[directionInfo.category];

    var directionSet  = null;
    var gDirection    = null;
    var dirSetCatIndex=-1;
    //find if a Direction exists for this cat/businessId
    for(var i=0,count=directionCat.length;i<count;i++)
    {
      if(directionCat[i] != null &&
         directionCat[i].directionInfo.category   ==
directionInfo.category &&
         directionCat[i].directionInfo.businessId ==
directionInfo.businessId
        )
      {
        directionSet   = directionCat[i]
        dirSetCatIndex = i;
      }
    }

    if(directionSet == null)
    {
      var directionDivId =
"GoogleMapsDirection_"+directionInfo.businessId;
      var directionDiv   = Ext.get(directionDivId);

      if(!directionDiv)
        Ext.get("GoogleMapsDirection").insertHtml('beforeEnd', '<div
id="'+directionDivId+'"></div>')

      $(directionDivId).title = directionInfo.title;

      gDirection = new GDirections(this.gmap, $(directionDivId));

      gDirection.category  = directionInfo.category  ;
      gDirection.businessId= directionInfo.businessId;
      gDirection.customId  = directionInfo.category
+'_'+directionInfo.businessId;
      GEvent.addListener(gDirection, "load"       , function(){
       //alert('loaded');
      });
      GEvent.addListener(gDirection, "error"      , function(){
       alert('gDirection error '+this.getStatus().code );
      });
//replace original marker by custom one
      GEvent.addListener(gDirection, "addoverlay" , function(){
        var originalFromMarker = this.getMarker(0);
        var originalFromLatLng = originalFromMarker.getLatLng();
        var originalToMarker   = this.getMarker(1);
        var originalToLatLng   = originalToMarker.getLatLng();

         var map      = Ext.getCmp('center-carte-paris-panel');
         var extraHtml = ['<br/>En mouvement : ',
                          '<b>distance :</b> ',
                          this.getDistance().html,
                          ', <b>durée :</b> ',
                          this.getDuration().html,
                          '<br/> depuis :<br/>',
                          directionInfo.fromAddress,
                          '<br/>à destination de : <br/>',
                          directionInfo.toAddress,
                          '<br/> <input type="button" value="Voir les
indications pour le trajet" onClick="Ext.getCmp(\'center-carte-paris-
panel\').showDirectionPath(\''+directionDivId+'\')"/>'];

         var html     = String.format(directionInfo.html,
extraHtml.join(''));

         map.addMarker(originalFromLatLng.lat (),
                       originalFromLatLng.lng (),
                       null                     ,
                       directionInfo.category   ,
                       false                    ,
                       directionInfo.title      ,
                       html                     ,
                       directionInfo.businessId ,
                       directionInfo.category+'_from');

         map.addMarker(originalToLatLng.lat   (),
                       originalToLatLng.lng   (),
                       null                     ,
                       directionInfo.category   ,
                       false                    ,
                       directionInfo.title      ,
                       html                     ,
                       directionInfo.businessId ,
                       directionInfo.category+'_to');

        map.removeMarker(originalFromMarker);
        map.removeMarker(originalToMarker  );
      }); // added to trigger marker swap

      directionSet = {directionInfo:directionInfo, gDirection:
gDirection};
      directionCat.push(directionSet);
    }
    else
    {//update the direction Info, keep the instance of gDirection
      directionSet.directionInfo=directionInfo;
    }
    directionSet.directionInfo.routeInstruction ="from: " +
directionSet.directionInfo.fromAddress+', france' + " to: " +
directionSet.directionInfo.toAddress+', france';
    directionSet.directionInfo.displayed=false;
  },


there's a lot of other code ...

Thomas

On 9 sep, 23:48, Rossko <[EMAIL PROTECTED]> wrote:
> >   I'm builing an application to handle the Red Cross ambulances in
> > action of Paris(France).
>
> You need to be aware of the Terms of Use.  For the free API,
> "dispatch, fleet management or similar applications" seem to be
> forbidden.  Red Cross may need to buy a licence.
>
> cheers, Ross K
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to