Get your own customer support community
 

Combining ACTransitMapProvider.as overlay with Yahoo etc.

I'm trying to figure out how to add a tiled image (similar to Zoomify, but created using my own image tiler) and overlay it on another map (such as Yahoo).

As a test, I adapted the HelloLayers example to use ACTransitMapProvider.as

I expected the maps to line up, but they don't.

Here's the code, but there's not much modification! I just replaced MicrosoftAerialMapProvider with ACTransitMapProvider

package {
import com.modestmaps.geo.Location;
import com.modestmaps.Map;
import com.modestmaps.mapproviders.ACTransitMapProvider;
import com.modestmaps.TweenMap;
import com.modestmaps.events.MapEvent;
import com.modestmaps.extras.MapControls;
import com.modestmaps.extras.MapCopyright;
import com.modestmaps.extras.ZoomSlider;
import com.modestmaps.mapproviders.microsoft.MicrosoftAerialMapProvider;
import com.modestmaps.mapproviders.yahoo.YahooAerialMapProvider;

import flash.display.BlendMode;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;

[SWF(backgroundColor="#000000")]
public class TestZoomify extends Sprite
{
public var map:Map;
public var overlay:Map;

public function TestZoomify()
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;

map = new TweenMap(stage.stageWidth, stage.stageHeight, true, new ACTransitMapProvider());
map.addEventListener(MouseEvent.DOUBLE_CLICK, map.onDoubleClick);
addChild(map);

overlay = new TweenMap(stage.stageWidth, stage.stageHeight, false, new YahooAerialMapProvider());
overlay.mouseChildren = overlay.mouseEnabled = false; // pass thru to map
addChild(overlay);

// you could adjust the alpha of your overlay here:
//overlay.alpha = 1;

// but I want to see how Microsoft and Yahoo's aerial imagery differs, so:
overlay.blendMode = BlendMode.DIFFERENCE;

// these *should* be all the events you need to watch out for
// fingers crossed!
map.addEventListener(MapEvent.EXTENT_CHANGED, syncMaps);
map.addEventListener(MapEvent.PANNED, syncMaps);
map.addEventListener(MapEvent.ZOOMED_BY, syncMaps);
map.addEventListener(MapEvent.STOP_ZOOMING, syncMaps);
map.addEventListener(MapEvent.STOP_PANNING, syncMaps);

// add these to the stage so they're on top of our overlay too
addChild(new MapControls(map));

// make sure the map fills the screen:
stage.addEventListener(Event.RESIZE, onStageResize);

map.setCenter(new Location(37.810665, -122.262297));
}

private function syncMaps(event:MapEvent=null):void
{
// if you're using TweenMap then you need to
// do this to get the animations synced:
overlay.grid.setMatrix(map.grid.getMatrix());

// if you're using 'Map' you can just do
// overlay.setCenterZoom(map.getCenter(), map.getZoom());
}

private function onStageResize(event:Event):void
{
map.setSize(stage.stageWidth, stage.stageHeight);
overlay.setSize(stage.stageWidth, stage.stageHeight);
syncMaps(); // just to be sure
}
}
}
 
sad I’m confused
Inappropriate?
1 person has this question

User_default_medium