Showing posts with label Modets maps. Show all posts
Showing posts with label Modets maps. Show all posts

Tuesday, June 9, 2009

Modest Maps and ArcGIS


I've been looking into hooking the Modest maps Flex client to ArcGIS. Just finished a basic demo for United maps.

I edited a dataprovider.as posted on the modest maps discussion board. Here is the code:

package com.modestmaps.mapproviders
{
import com.modestmaps.core.Coordinate;
import com.modestmaps.mapproviders.AbstractMapProvider;
import com.modestmaps.mapproviders.IMapProvider;
import com.modestmaps.geo.LinearProjection;
import com.modestmaps.geo.Transformation;

public class EsriMapProvider extends AbstractMapProvider implements IMapProvider
{
public function EsriMapProvider(minZoom:int=MIN_ZOOM, maxZoom:int=MAX_ZOOM)
{
super(minZoom, Math.min(20, maxZoom));

var t:Transformation = new Transformation(0.3183098861837907, 0, 1, 0, -0.3183098861837907, 0.5);
__projection = new LinearProjection(0, t);

}

override public function sourceCoordinate(coord:Coordinate):Coordinate
{
var tilesWide:int = Math.pow(2, coord.zoom+1);

var wrappedColumn:Number = coord.column % tilesWide;

while (wrappedColumn < 0)
{
wrappedColumn += tilesWide;
}

return new Coordinate(coord.row, wrappedColumn, coord.zoom);
}

public function toString():String
{
return "ESRI";
}

public function getTileUrls(coord:Coordinate):Array
{
//return [ "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/tile/" + getZoomString(sourceCoordinate(coord)) ];
return [ "http://..../ArcGIS/rest/services/MUC_Basemap/MapServer/tile/" + getZoomString(sourceCoordinate(coord)) ];
//return [ "http://..../umapserver/mapdijits/config/proxy.ashx?http://..../ArcGIS/rest/services/MUC_Basemap/MapServer/tile/" + getZoomString(sourceCoordinate(coord)) ];
}

protected function getZoomString( coord : Coordinate ) : String
{
var sourceCoord:Coordinate = sourceCoordinate(coord)
return (sourceCoord.zoom) + "/" + (sourceCoord.row) + "/" +(sourceCoord.column) ;
}

}
}