Upgrading to 6.0 (Pois Geocoder / Decluttering)

Ok, so the POI changes went pretty quick to get back to what I had before without decluttering considered.  The biggest change was changing all the old objects into the new object. Before(with 5.3), I used the GeoAddress and the Address.  I used those a lot when I had all the information that I needed and when I didn’t.  I could make a GeoAddress.  So to replace the GeoAddress we now use the GeocoderLocation.  This typically comes back from the service, but you can create one at any time.  Give it the appropriate information and then create a POI from that information, or pass it to their service, create the whole GeocoderLocation and then create the function.  A quick example would be good to show.

 function addPoi(object)
{
    if(object.location != null)
    {
      var geoLocation:GeocoderLocation = new GeocoderLocation;
      //set all the GeocoderLocation stuff here
     makePoi(geoLocation);
    }
    else
    {
     var geoCoder:Geocoder = new Geocoder(new MapConstants().MAP_KEY);
     
var address:GeocoderLocation = new GeocoderLocation();

     geoCoder.addEventListener(GeocoderEvent.GEOCODE_RESPONSE, ProperResult);
     geoCoder.addEventListener(GeocoderEvent.GEOCODE_ERROR_EVENT, SearchError);
     geoCoder.addEventListener(GeocoderEvent.HTTP_ERROR_EVENT, HTTPError);
     address.street = lampoPoi.getAddressLampo().getStreet1();
     address.city = lampoPoi.getAddressLampo().getCity();
     address.state = lampoPoi.getAddressLampo().getStateCode();
     address.postalCode = lampoPoi.getAddressLampo().getPostalCode();
     geoCoder.geocode(geoLocation);
    }
}
 

public function ProperResult(evt:GeocoderEvent):void
{
     makePoi(geoLocation);
}

 

Decluttering is actually much easier to change than I thought.  This simple function will make you decluttering work in 6.0.  Before I was thinking you would have to put everything in a shape collection but actually you can just call it on the map itself.  This is really nice to be able to do.  THANKS MAPQUEST!  Oh and there is Animation added now.  Pretty sweet.

  private function initDeclutter():void
{
 var cd:IDeclutter;
 cd =  new ForceDeclutter();
 var lines:LeaderLines = new LeaderLines();
 this.myMap.leaderLines = lines;
 this.myMap.declutter = cd;
}

Advertisement

About this entry