Ok, so this post probably won’t be long because this is so super simple! So first the atta boy to MapQuest for making this so simple. Now lets look at what it takes.
The tilemap is what actually need the setting done, so in your code you can say:
myMap.getDeclutterMode().setDeclutterMode(2);
//you can also use 1 but in my opinion 2 looks much more intuitive. 0 will set it back to no decluttering
So on the baseline that is it. So if you extend the map you can actually catch some neat functionality. Do the following to get a neat declutter when hitting a specific zoom level or breaking a zoom level barrier. A quick word of advice. Declutter in mode 2 might make the flash player take longer than hoped on large data sets. If this is the case you might want to do something like below or even turn off deluttering when retrieving POIs then turn it on once you put them on the map. I found that it took the player some significant time to show the POIs when I have too many POIs.
/* This function will turn on decluttering of the pois when the zoom levels reach optimal position. */
public function setDeclutterByZoom(e:TileMapEvent):void
{
if(this.getZoomLevel() >= 7)this.getDeclutter().setDeclutterMode(2);
else
this.getDeclutter().setDeclutterMode(0);
return
}
Like I said before I like to use 2 because it looks much easier to the users I have.
If your users like this then you might want to also grab the dragable ability of the POIs. But if you have a complex application you might run into a problem if you are running an event listener on a mouseup, mousedown or something of that nature on the map. I was doing that because it was the simple thing at the time because I was waiting for a Click For Drag so I could recenter my map. So I made sure I moved that event and it worked flawlessly. Just add the following line to your POI.
myPoi.setDraggable(true);
You can also add use this function to let your users drop those POIs where ever they want. Just drag and drop, all done!
myPoi.setSnapback(false);
This is pretty striaght forward stuff, but really watch you events as it will have some crazy interaction with the POI dragability.