├── .gitignore ├── docs ├── images │ ├── logo.jpg │ ├── expanded.gif │ ├── collapsed.gif │ ├── inherit-arrow.gif │ ├── titleTableTop.jpg │ ├── detailHeaderRule.jpg │ ├── inheritedSummary.gif │ ├── titleTableBottom.jpg │ ├── titleTableMiddle.jpg │ └── detailSectionHeader.jpg ├── com │ └── modestmaps │ │ ├── util │ │ ├── class-list.html │ │ └── package-detail.html │ │ ├── flex │ │ ├── class-list.html │ │ └── package-detail.html │ │ ├── class-list.html │ │ ├── events │ │ ├── class-list.html │ │ └── package-detail.html │ │ ├── extras │ │ ├── ui │ │ │ ├── class-list.html │ │ │ └── package-detail.html │ │ └── class-list.html │ │ ├── core │ │ ├── class-list.html │ │ └── package-detail.html │ │ ├── mapproviders │ │ ├── yahoo │ │ │ ├── class-list.html │ │ │ └── package-detail.html │ │ ├── microsoft │ │ │ ├── class-list.html │ │ │ └── package-detail.html │ │ └── class-list.html │ │ ├── overlays │ │ └── class-list.html │ │ ├── geo │ │ ├── class-list.html │ │ └── package-detail.html │ │ └── package-detail.html ├── gs │ ├── class-list.html │ └── package-detail.html ├── package-frame.html ├── mxml-tags.html ├── index.html ├── index-list.html ├── appendixes.html ├── print.css ├── cookies.js ├── package-list.html └── title-bar.html ├── com └── modestmaps │ ├── extras │ ├── hand.png │ ├── hand_down.png │ ├── LineStyle.hx │ ├── KeyHandler.hx │ ├── Distance.hx │ ├── VirtualEarthCopyright.hx │ ├── Overlay.hx │ ├── ui │ │ └── Button.hx │ ├── ZoomBox.hx │ ├── MapScale.hx │ ├── GreatCircleOverlay.hx │ └── HandCursor.hx │ ├── core │ ├── painter │ │ ├── ITilePainterOverride.hx │ │ ├── ITilePainter.hx │ │ ├── TileQueue.hx │ │ ├── TilePool.hx │ │ └── TileCache.hx │ ├── TweenTile.hx │ ├── Coordinate.hx │ └── Tile.hx │ ├── overlays │ ├── Redrawable.hx │ ├── PolygonClip.hx │ └── Polyline.hx │ ├── mapproviders │ ├── microsoft │ │ ├── MicrosoftRoadMapProvider.hx │ │ ├── MicrosoftHybridMapProvider.hx │ │ ├── MicrosoftAerialMapProvider.hx │ │ └── MicrosoftProvider.hx │ ├── BlankProvider.hx │ ├── OpenStreetMapProvider.hx │ ├── google │ │ └── GoogleMapProvider.hx │ ├── yahoo │ │ ├── YahooOverlayMapProvider.hx │ │ ├── YahooRoadMapProvider.hx │ │ ├── YahooAerialMapProvider.hx │ │ └── YahooHybridMapProvider.hx │ ├── BlueMarbleMapProvider.hx │ ├── ACTransitMapProvider.hx │ ├── IMapProvider.hx │ ├── CloudMadeProvider.hx │ ├── CartoDBProvider.hx │ ├── DynamicZoomifyMapProvider.hx │ ├── DailyPlanetProvider.hx │ ├── AbstractMapProvider.hx │ ├── AbstractZoomifyMapProvider.hx │ └── WMSMapProvider.hx │ ├── geo │ ├── IProjection.hx │ ├── LinearProjection.hx │ ├── MercatorProjection.hx │ ├── Transformation.hx │ ├── Location.hx │ └── AbstractProjection.hx │ ├── events │ ├── MarkerEvent.hx │ └── MapEvent.hx │ └── util │ └── BinaryUtil.hx ├── README.md └── samples ├── ModestMapsSample ├── src │ ├── DemoPolygons.hx │ ├── SampleMarker.hx │ ├── Tooltip.hx │ ├── MapProviderButton.hx │ └── DemoMarkers.hx ├── project.xml └── ModestMapsSample.hxproj └── old_ModestMapsExamples └── src ├── HelloMap.hx ├── HelloPolygons.hx ├── HelloExtras.hx ├── com └── pixelbreaker │ └── ui │ └── osx │ └── MacMouseWheel.hx ├── HelloLayers.hx ├── HelloWMS.hx ├── HelloMarkers.hx ├── HelloCustomTiles.hx └── HelloESRI.hx /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | -------------------------------------------------------------------------------- /docs/images/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmauri/modestmaps-openfl/HEAD/docs/images/logo.jpg -------------------------------------------------------------------------------- /docs/images/expanded.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmauri/modestmaps-openfl/HEAD/docs/images/expanded.gif -------------------------------------------------------------------------------- /docs/images/collapsed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmauri/modestmaps-openfl/HEAD/docs/images/collapsed.gif -------------------------------------------------------------------------------- /docs/images/inherit-arrow.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmauri/modestmaps-openfl/HEAD/docs/images/inherit-arrow.gif -------------------------------------------------------------------------------- /docs/images/titleTableTop.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmauri/modestmaps-openfl/HEAD/docs/images/titleTableTop.jpg -------------------------------------------------------------------------------- /com/modestmaps/extras/hand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmauri/modestmaps-openfl/HEAD/com/modestmaps/extras/hand.png -------------------------------------------------------------------------------- /docs/images/detailHeaderRule.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmauri/modestmaps-openfl/HEAD/docs/images/detailHeaderRule.jpg -------------------------------------------------------------------------------- /docs/images/inheritedSummary.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmauri/modestmaps-openfl/HEAD/docs/images/inheritedSummary.gif -------------------------------------------------------------------------------- /docs/images/titleTableBottom.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmauri/modestmaps-openfl/HEAD/docs/images/titleTableBottom.jpg -------------------------------------------------------------------------------- /docs/images/titleTableMiddle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmauri/modestmaps-openfl/HEAD/docs/images/titleTableMiddle.jpg -------------------------------------------------------------------------------- /com/modestmaps/extras/hand_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmauri/modestmaps-openfl/HEAD/com/modestmaps/extras/hand_down.png -------------------------------------------------------------------------------- /docs/images/detailSectionHeader.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mmauri/modestmaps-openfl/HEAD/docs/images/detailSectionHeader.jpg -------------------------------------------------------------------------------- /com/modestmaps/core/painter/ITilePainterOverride.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.core.painter; 2 | 3 | interface ITilePainterOverride 4 | { 5 | 6 | function getTilePainter() : ITilePainter; 7 | } 8 | -------------------------------------------------------------------------------- /com/modestmaps/overlays/Redrawable.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.overlays; 2 | 3 | import openfl.events.Event; 4 | 5 | /** used by PolygonClip to trigger a redraw when zoom levels have changed substantially */ 6 | interface Redrawable 7 | { 8 | 9 | function redraw(event : Event = null) : Void; 10 | } 11 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/microsoft/MicrosoftRoadMapProvider.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.mapproviders.microsoft; 2 | 3 | /** 4 | * @author darren 5 | * $Id$ 6 | */ 7 | class MicrosoftRoadMapProvider extends MicrosoftProvider 8 | { 9 | public function new(hillShading : Bool = true, minZoom : Int = AbstractMapProvider.MIN_ZOOM, maxZoom : Int = AbstractMapProvider.MAX_ZOOM) 10 | { 11 | super(MicrosoftProvider.ROAD, hillShading, minZoom, maxZoom); 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/microsoft/MicrosoftHybridMapProvider.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.mapproviders.microsoft; 2 | 3 | import com.modestmaps.mapproviders.microsoft.MicrosoftProvider; 4 | 5 | /** 6 | * @author darren 7 | * $Id$ 8 | */ 9 | class MicrosoftHybridMapProvider extends MicrosoftProvider 10 | { 11 | public function new(minZoom : Int = AbstractMapProvider.MIN_ZOOM, maxZoom : Int = AbstractMapProvider.MAX_ZOOM) 12 | { 13 | super(MicrosoftProvider.HYBRID, true, minZoom, maxZoom); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/microsoft/MicrosoftAerialMapProvider.hx: -------------------------------------------------------------------------------- 1 | 2 | package com.modestmaps.mapproviders.microsoft; 3 | 4 | import com.modestmaps.mapproviders.microsoft.MicrosoftProvider; 5 | 6 | /** 7 | * @author darren 8 | * $Id$ 9 | */ 10 | class MicrosoftAerialMapProvider extends MicrosoftProvider 11 | { 12 | public function new(minZoom : Int = AbstractMapProvider.MIN_ZOOM, maxZoom : Int = AbstractMapProvider.MAX_ZOOM) 13 | { 14 | super(MicrosoftProvider.AERIAL, true, minZoom, maxZoom); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # modestmaps-openfl 2 | Modestmaps Haxe/OpenFL port from modestmaps-as3 by migurski 3 | https://github.com/migurski/modestmaps-as3 4 | 5 | HTML5 Demo 6 | https://mmauri.github.io 7 | 8 | Install from haxelib (Haxe 3.4 & latest openfl recommended) 9 | 10 | haxelib git modestmaps-openfl https://github.com/mmauri/modestmaps-openfl 11 | 12 | Change dir to haxelib location (default install path in c:\haxetoolkit\haxe\lib) 13 | cd modestmaps-openfl\git\samples\ModestMapsSample 14 | 15 | HTML5 -> openfl test html5 16 | Flash -> openfl test flash 17 | Android -> openfl test android 18 | iOS -> openfl test ios (needs to run in mac) 19 | 20 | mac & windows not tested yet 21 | 22 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/BlankProvider.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.mapproviders; 2 | import com.modestmaps.core.Coordinate; 3 | 4 | class BlankProvider extends AbstractMapProvider implements IMapProvider 5 | { 6 | public function getTileUrls(coord : Coordinate) : Array 7 | { 8 | return []; 9 | } 10 | 11 | public function toString() : String 12 | { 13 | return "BLANK_PROVIDER"; 14 | } 15 | 16 | override private function get_tileWidth() : Int 17 | { 18 | return 32; 19 | } 20 | 21 | override private function get_tileHeight() : Int 22 | { 23 | return 32; 24 | } 25 | 26 | public function new() 27 | { 28 | super(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /com/modestmaps/geo/IProjection.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | */ 4 | 5 | package com.modestmaps.geo; 6 | 7 | import com.modestmaps.core.Coordinate; 8 | import com.modestmaps.geo.Location; 9 | import openfl.geom.Point; 10 | 11 | interface IProjection 12 | { 13 | 14 | /* 15 | * Return projected and transformed point. 16 | */ 17 | function project(point : Point) : Point; 18 | 19 | /* 20 | * Return untransformed and unprojected point. 21 | */ 22 | function unproject(point : Point) : Point; 23 | 24 | /* 25 | * Return projected and transformed coordinate for a location. 26 | */ 27 | function locationCoordinate(location : Location) : Coordinate; 28 | 29 | /* 30 | * Return untransformed and unprojected location for a coordinate. 31 | */ 32 | function coordinateLocation(coordinate : Coordinate) : Location; 33 | 34 | function toString() : String; 35 | } 36 | -------------------------------------------------------------------------------- /docs/com/modestmaps/util/class-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.modestmaps.util - API Documentation 6 | 7 | 8 | 9 | 10 | 11 |

12 | Package com.modestmaps.util 13 |

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
Classes
BinaryUtil
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /docs/com/modestmaps/flex/class-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.modestmaps.flex - API Documentation 6 | 7 | 8 | 9 | 10 | 11 |

12 | Package com.modestmaps.flex 13 |

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
Classes
MapComponent
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /docs/gs/class-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | gs - API Documentation 6 | 7 | 8 | 9 | 10 | 11 |

12 | Package gs 13 |

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
Classes
TweenFilterLite
TweenLite
25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /docs/com/modestmaps/class-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.modestmaps - API Documentation 6 | 7 | 8 | 9 | 10 | 11 |

12 | Package com.modestmaps 13 |

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
Classes
Map
TweenMap
25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /com/modestmaps/core/painter/ITilePainter.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.core.painter; 2 | 3 | 4 | import com.modestmaps.core.Coordinate; 5 | import com.modestmaps.core.Tile; 6 | import com.modestmaps.mapproviders.IMapProvider; 7 | import openfl.events.IEventDispatcher; 8 | 9 | 10 | interface ITilePainter extends IEventDispatcher 11 | { 12 | 13 | function setTileClass(isTweenTile : Bool) : Void; 14 | function setMapProvider(provider : IMapProvider) : Void; 15 | function getTileFromCache(key : String) : Tile; 16 | function retainKeysInCache(recentlySeen : Array) : Void; 17 | function createAndPopulateTile(coord : Coordinate, key : String) : Tile; 18 | function isPainted(tile : Tile) : Bool; 19 | function cancelPainting(tile : Tile) : Void; 20 | function isPainting(tile : Tile) : Bool; 21 | function reset() : Void; 22 | function getLoaderCacheCount() : Int; 23 | function getQueueCount() : Int; 24 | function getRequestCount() : Int; 25 | function getCacheSize() : Int; 26 | } 27 | -------------------------------------------------------------------------------- /com/modestmaps/geo/LinearProjection.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | */ 4 | 5 | package com.modestmaps.geo; 6 | 7 | import com.modestmaps.geo.AbstractProjection; 8 | import com.modestmaps.geo.Transformation; 9 | import openfl.geom.Point; 10 | 11 | class LinearProjection extends AbstractProjection 12 | { 13 | private function new(zoom : Float, T : Transformation) 14 | { 15 | super(zoom, T); 16 | } 17 | 18 | /* 19 | * String signature of the current projection. 20 | */ 21 | override public function toString() : String 22 | { 23 | return "Linear(" + zoom + ", " + Std.string(T) + ")"; 24 | } 25 | 26 | /* 27 | * Return raw projected point. 28 | */ 29 | override private function rawProject(point : Point) : Point 30 | { 31 | return new Point(point.x, point.y); 32 | } 33 | 34 | /* 35 | * Return raw unprojected point. 36 | */ 37 | override private function rawUnproject(point : Point) : Point 38 | { 39 | return new Point(point.x, point.y); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/OpenStreetMapProvider.hx: -------------------------------------------------------------------------------- 1 | /** 2 | * MapProvider for Open Street Map data. 3 | * 4 | * @author migurski 5 | * $Id$ 6 | */ 7 | package com.modestmaps.mapproviders; 8 | 9 | import com.modestmaps.core.Coordinate; 10 | 11 | class OpenStreetMapProvider extends AbstractMapProvider implements IMapProvider 12 | { 13 | public function new(minZoom : Int = AbstractMapProvider.MIN_ZOOM, maxZoom : Int = AbstractMapProvider.MAX_ZOOM) 14 | { 15 | super(minZoom, maxZoom); 16 | } 17 | 18 | public function toString() : String 19 | { 20 | return "OPEN_STREET_MAP"; 21 | } 22 | 23 | public function getTileUrls(coord : Coordinate) : Array 24 | { 25 | var sourceCoord : Coordinate = sourceCoordinate(coord); 26 | if (sourceCoord.row < 0 || sourceCoord.row >= Math.pow(2, coord.zoom)) 27 | { 28 | return []; 29 | } 30 | return ["http://tile.openstreetmap.org/" + (sourceCoord.zoom) + "/" + (sourceCoord.column) + "/" + (sourceCoord.row) + ".png"]; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /docs/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Adobe Flex 2 Language Reference 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | <body> 20 | 21 | <h2>Frame Alert</h2> 22 | 23 | <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 24 | <br> 25 | Link to<a href="package-summary.html">Non-frame version.</a> 26 | 27 | </p> 28 | 29 | </body> 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/com/modestmaps/events/class-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.modestmaps.events - API Documentation 6 | 7 | 8 | 9 | 10 | 11 |

12 | Package com.modestmaps.events 13 |

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
Classes
MapEvent
MarkerEvent
25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /samples/ModestMapsSample/src/DemoPolygons.hx: -------------------------------------------------------------------------------- 1 | package; 2 | import com.modestmaps.TweenMap; 3 | import com.modestmaps.geo.Location; 4 | import com.modestmaps.core.MapExtent; 5 | import com.modestmaps.overlays.PolygonClip; 6 | import com.modestmaps.overlays.PolygonMarker; 7 | 8 | /** 9 | * ... 10 | * @author mmp 11 | */ 12 | class DemoPolygons 13 | { 14 | 15 | public function new(map : TweenMap) 16 | { 17 | var polygonClip : PolygonClip = new PolygonClip(map); 18 | 19 | var locations : Array = [new Location(37.83435, 21.36860), 20 | new Location(37.83435, 21.58489), 21 | new Location(37.78105, 21.58489), 22 | new Location(37.78105, 21.36860)]; 23 | 24 | var polygon : PolygonMarker = new PolygonMarker(map, locations, true); 25 | 26 | polygonClip.attachMarker(polygon, polygon.location); 27 | 28 | map.addChild(polygonClip); 29 | 30 | map.setExtent(MapExtent.fromLocations(locations)); 31 | 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/google/GoogleMapProvider.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.mapproviders.google; 2 | 3 | import com.modestmaps.core.Coordinate; 4 | import com.modestmaps.core.painter.GoogleTilePainter; 5 | import com.modestmaps.core.painter.ITilePainter; 6 | import com.modestmaps.core.painter.ITilePainterOverride; 7 | import com.modestmaps.mapproviders.AbstractMapProvider; 8 | import com.modestmaps.mapproviders.IMapProvider; 9 | 10 | class GoogleMapProvider extends AbstractMapProvider implements IMapProvider implements ITilePainterOverride 11 | { 12 | private var tilePainter : GoogleTilePainter; 13 | 14 | public function new(tilePainter : GoogleTilePainter) 15 | { 16 | super(); 17 | this.tilePainter = tilePainter; 18 | } 19 | 20 | public function getTilePainter() : ITilePainter 21 | { 22 | return tilePainter; 23 | } 24 | 25 | public function toString() : String 26 | { 27 | return Std.string(tilePainter); 28 | } 29 | 30 | public function getTileUrls(coord : Coordinate) : Array 31 | { 32 | return []; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /docs/com/modestmaps/extras/ui/class-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.modestmaps.extras.ui - API Documentation 6 | 7 | 8 | 9 | 10 | 11 |

12 | Package com.modestmaps.extras.ui 13 |

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
Classes
Button
FullScreenButton
25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /samples/ModestMapsSample/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/yahoo/YahooOverlayMapProvider.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.mapproviders.yahoo; 2 | 3 | import com.modestmaps.core.Coordinate; 4 | import com.modestmaps.mapproviders.AbstractMapProvider; 5 | import com.modestmaps.mapproviders.IMapProvider; 6 | 7 | /** 8 | * @author darren 9 | * $Id$ 10 | */ 11 | class YahooOverlayMapProvider extends AbstractMapProvider implements IMapProvider 12 | { 13 | public function new(minZoom : Int = MIN_ZOOM, maxZoom : Int = MAX_ZOOM) 14 | { 15 | super(minZoom, maxZoom); 16 | } 17 | 18 | public function toString() : String 19 | { 20 | return "YAHOO_OVERLAY"; 21 | } 22 | 23 | public function getTileUrls(coord : Coordinate) : Array 24 | { 25 | return ["http://us.maps3.yimg.com/aerial.maps.yimg.com/img?md=200608221700&v=2.0&t=h" + getZoomString(sourceCoordinate(coord))]; 26 | } 27 | 28 | private function getZoomString(coord : Coordinate) : String 29 | { 30 | var row : Float = (Math.pow(2, coord.zoom) / 2) - coord.row - 1; 31 | return "&x=" + coord.column + "&y=" + row + "&z=" + (18 - coord.zoom); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/yahoo/YahooRoadMapProvider.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.mapproviders.yahoo; 2 | 3 | import com.modestmaps.core.Coordinate; 4 | import com.modestmaps.mapproviders.AbstractMapProvider; 5 | import com.modestmaps.mapproviders.IMapProvider; 6 | 7 | /** 8 | * @author darren 9 | * $Id$ 10 | */ 11 | class YahooRoadMapProvider extends AbstractMapProvider implements IMapProvider 12 | { 13 | public function new(minZoom : Int = AbstractMapProvider.MIN_ZOOM, maxZoom : Int = AbstractMapProvider.MAX_ZOOM) 14 | { 15 | super(minZoom, maxZoom); 16 | } 17 | 18 | public function toString() : String 19 | { 20 | return "YAHOO_ROAD"; 21 | } 22 | 23 | public function getTileUrls(coord : Coordinate) : Array 24 | { 25 | return ["http://us.maps2.yimg.com/us.png.maps.yimg.com/png?v=3.52&t=m" + getZoomString(sourceCoordinate(coord))]; 26 | } 27 | 28 | private function getZoomString(coord : Coordinate) : String 29 | { 30 | var row : Float = (Math.pow(2, coord.zoom) / 2) - coord.row - 1; 31 | return "&x=" + coord.column + "&y=" + row + "&z=" + (18 - coord.zoom); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/yahoo/YahooAerialMapProvider.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.mapproviders.yahoo; 2 | 3 | import com.modestmaps.core.Coordinate; 4 | import com.modestmaps.mapproviders.AbstractMapProvider; 5 | import com.modestmaps.mapproviders.IMapProvider; 6 | 7 | /** 8 | * @author darren 9 | * $Id$ 10 | */ 11 | class YahooAerialMapProvider extends AbstractMapProvider implements IMapProvider 12 | { 13 | public function new(minZoom : Int = AbstractMapProvider.MIN_ZOOM, maxZoom : Int = AbstractMapProvider.MAX_ZOOM) 14 | { 15 | super(minZoom, maxZoom); 16 | } 17 | 18 | public function toString() : String 19 | { 20 | return "YAHOO_AERIAL"; 21 | } 22 | 23 | public function getTileUrls(coord : Coordinate) : Array 24 | { 25 | return ["http://us.maps3.yimg.com/aerial.maps.yimg.com/tile?v=1.7&t=a" + getZoomString(sourceCoordinate(coord))]; 26 | } 27 | 28 | private function getZoomString(coord : Coordinate) : String 29 | { 30 | var row : Float = (Math.pow(2, coord.zoom) / 2) - coord.row - 1; 31 | return "&x=" + coord.column + "&y=" + row + "&z=" + (18 - coord.zoom); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /com/modestmaps/extras/LineStyle.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.extras; 2 | 3 | import openfl.display.Graphics; 4 | 5 | class LineStyle 6 | { 7 | public var thickness : Float; 8 | public var color : Int; 9 | public var alpha : Float; 10 | public var pixelHinting : Bool; 11 | public var scaleMode : String; 12 | public var caps : String; 13 | public var joints : String; 14 | public var miterLimit : Float; 15 | 16 | public function new(thickness : Float = 0, color : Int = 0, alpha : Float = 1, pixelHinting : Bool = false, scaleMode : String = "normal", caps : String = null, joints : String = null, miterLimit : Float = 3.0) 17 | { 18 | this.thickness = thickness; 19 | this.color = color; 20 | this.alpha = alpha; 21 | this.pixelHinting = pixelHinting; 22 | this.scaleMode = scaleMode; 23 | this.caps = caps; 24 | this.joints = joints; 25 | this.miterLimit = miterLimit; 26 | } 27 | 28 | public function apply(graphics : Graphics, thicknessMod : Float = 1, alphaMod : Float = 1) : Void 29 | { 30 | graphics.lineStyle(thickness * thicknessMod, color, alpha * alphaMod, pixelHinting, scaleMode, caps, joints, miterLimit); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/BlueMarbleMapProvider.hx: -------------------------------------------------------------------------------- 1 | /** 2 | * @author migurski 3 | * $Id$ 4 | */ 5 | package com.modestmaps.mapproviders; 6 | 7 | import com.modestmaps.core.Coordinate; 8 | import com.modestmaps.mapproviders.IMapProvider; 9 | 10 | 11 | class BlueMarbleMapProvider extends AbstractMapProvider implements IMapProvider 12 | { 13 | public var baseURL : String; 14 | 15 | public function new(minZoom : Int = AbstractMapProvider.MIN_ZOOM, maxZoom : Int = AbstractMapProvider.MAX_ZOOM) 16 | { 17 | super(minZoom, Math.min(9, maxZoom)); 18 | if (baseURL == null) 19 | baseURL = "http://s3.amazonaws.com/com.modestmaps.bluemarble/"; 20 | } 21 | 22 | public function toString() : String 23 | { 24 | return "BLUE_MARBLE"; 25 | } 26 | 27 | public function getTileUrls(coord : Coordinate) : Array 28 | { 29 | var sourceCoord : Coordinate = sourceCoordinate(coord); 30 | if (sourceCoord.row < 0 || sourceCoord.row >= Math.pow(2, coord.zoom)) 31 | { 32 | return []; 33 | } 34 | return [baseURL + (sourceCoord.zoom) + "-r" + (sourceCoord.row) + "-c" + (sourceCoord.column) + ".jpg"]; 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /com/modestmaps/events/MarkerEvent.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | */ 4 | 5 | package com.modestmaps.events; 6 | 7 | import com.modestmaps.geo.Location; 8 | import openfl.display.DisplayObject; 9 | import openfl.events.Event; 10 | 11 | class MarkerEvent extends Event 12 | { 13 | public var marker(get, never) : DisplayObject; 14 | public var location(get, never) : Location; 15 | 16 | // these are prefixed marker to avoid conflicts with MouseEvent 17 | public static inline var MARKER_ROLL_OVER : String = "markerRollOver"; 18 | public static inline var MARKER_ROLL_OUT : String = "markerRollOut"; 19 | public static inline var MARKER_CLICK : String = "markerClick"; 20 | 21 | private var _marker : DisplayObject; 22 | private var _location : Location; 23 | 24 | public function new(type : String, marker : DisplayObject, location : Location, bubbles : Bool = true, cancelable : Bool = false) 25 | { 26 | super(type, bubbles, cancelable); 27 | _marker = marker; 28 | _location = location; 29 | } 30 | 31 | private function get_marker() : DisplayObject 32 | { 33 | return _marker; 34 | } 35 | 36 | private function get_location() : Location 37 | { 38 | return _location; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/yahoo/YahooHybridMapProvider.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.mapproviders.yahoo; 2 | 3 | import com.modestmaps.core.Coordinate; 4 | import com.modestmaps.mapproviders.AbstractMapProvider; 5 | import com.modestmaps.mapproviders.IMapProvider; 6 | 7 | /** 8 | * @author darren 9 | * $Id$ 10 | */ 11 | class YahooHybridMapProvider extends AbstractMapProvider implements IMapProvider 12 | { 13 | public function new(minZoom : Int = AbstractMapProvider.MIN_ZOOM, maxZoom : Int = AbstractMapProvider.MAX_ZOOM) 14 | { 15 | super(minZoom, maxZoom); 16 | } 17 | 18 | public function toString() : String 19 | { 20 | return "YAHOO_HYBRID"; 21 | } 22 | 23 | public function getTileUrls(coord : Coordinate) : Array 24 | { 25 | return ["http://us.maps3.yimg.com/aerial.maps.yimg.com/tile?v=1.7&t=a" + getZoomString(sourceCoordinate(coord)), 26 | "http://us.maps3.yimg.com/aerial.maps.yimg.com/png?v=2.2&t=h" + getZoomString(sourceCoordinate(coord))]; 27 | } 28 | 29 | private function getZoomString(coord : Coordinate) : String 30 | { 31 | var row : Float = (Math.pow(2, coord.zoom) / 2) - coord.row - 1; 32 | return "&x=" + coord.column + "&y=" + row + "&z=" + (18 - coord.zoom); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /com/modestmaps/core/TweenTile.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * vim:et sts=4 sw=4 cindent: 3 | * $Id$ 4 | */ 5 | 6 | package com.modestmaps.core; 7 | import motion.Actuate; 8 | 9 | class TweenTile extends Tile 10 | { 11 | public static inline var FADE_TIME : Float = 0.25; 12 | 13 | public function new(col : Int, row : Int, zoom : Int) 14 | { 15 | super(col, row, zoom); 16 | } 17 | 18 | override public function hide() : Void 19 | { 20 | // *** don't *** kill the tweens when hiding 21 | // it seems there's a harmless bug where hide might get called after show 22 | // if there's a tween running it will correct it though :) 23 | //TweenLite.killTweensOf(this); 24 | this.alpha = 0; 25 | } 26 | 27 | override public function show() : Void 28 | { 29 | if (alpha < 1) 30 | { 31 | 32 | Actuate.tween(this, FADE_TIME, 33 | { 34 | alpha : 1 35 | }); 36 | } 37 | } 38 | 39 | override public function showNow() : Void 40 | { 41 | //TweenLite.killTweensOf(this); 42 | Actuate.stop(this,null,true); 43 | this.alpha = 1; 44 | } 45 | 46 | override public function destroy() : Void 47 | { 48 | //TweenLite.killTweensOf(this); 49 | Actuate.stop(this,null,false,false); 50 | super.destroy(); 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /docs/com/modestmaps/core/class-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.modestmaps.core - API Documentation 6 | 7 | 8 | 9 | 10 | 11 |

12 | Package com.modestmaps.core 13 |

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
Classes
Coordinate
MapExtent
Tile
TileGrid
TweenTile
34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/mxml-tags.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | MXML Only Components - Adobe Flex 2 Language Reference 10 | 11 | 12 | 13 | 14 | 15 | 16 |

MXML Only Components

17 | 18 | <mx:Binding> 19 |
20 | 21 | <mx:Component> 22 |
23 | 24 | <mx:Metadata> 25 |
26 | 27 | <mx:Model> 28 |
29 | 30 | <mx:Script> 31 |
32 | 33 | <mx:Style> 34 |
35 | 36 | <mx:XML> 37 |
38 | 39 | <mx:XMLList> 40 |
41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /com/modestmaps/geo/MercatorProjection.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | */ 4 | 5 | package com.modestmaps.geo; 6 | 7 | import com.modestmaps.geo.AbstractProjection; 8 | import com.modestmaps.geo.Transformation; 9 | import openfl.geom.Point; 10 | 11 | class MercatorProjection extends AbstractProjection 12 | { 13 | public function new(zoom : Float, T : Transformation) 14 | { 15 | super(zoom, T); 16 | } 17 | 18 | /* 19 | * String signature of the current projection. 20 | */ 21 | override public function toString() : String 22 | { 23 | return "Mercator(" + zoom + ", " + Std.string(T) + ")"; 24 | } 25 | 26 | /* 27 | * Return raw projected point. 28 | * See: http://mathworld.wolfram.com/MercatorProjection.html (2) 29 | */ 30 | override private function rawProject(point : Point) : Point 31 | { 32 | return new Point(point.x, 33 | Math.log(Math.tan(0.25 * Math.PI + 0.5 * point.y))); 34 | } 35 | 36 | /* 37 | * Return raw unprojected point. 38 | * See: http://mathworld.wolfram.com/MercatorProjection.html (7) 39 | */ 40 | override private function rawUnproject(point : Point) : Point 41 | { 42 | return new Point(point.x, 2 * Math.atan(Math.pow(Math.exp(1.0), point.y)) - 0.5 * Math.PI); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/ACTransitMapProvider.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.mapproviders; 2 | 3 | import com.modestmaps.geo.MercatorProjection; 4 | import com.modestmaps.geo.Transformation; 5 | import com.modestmaps.mapproviders.IMapProvider; 6 | 7 | 8 | class ACTransitMapProvider extends AbstractZoomifyMapProvider implements IMapProvider 9 | { 10 | public function new() 11 | { 12 | super(); 13 | defineImageProperties("http://actransit.modestmaps.com/", 11258, 7085); 14 | 15 | /* 16 | * Euclid Ave. & Ridge Rd., Berkeley 17 | * 37.876022, -122.260365 18 | * = coord(2296, 172, 14) 19 | * 20 | * Monarch St. & W. Tower Ave., Alameda 21 | * 37.783503, -122.308559 22 | * = coord(7061, 3350, 14) 23 | * 24 | * 140th Ave. & E 14th. St., Oakland 25 | * 37.713159, -122.139795 26 | * = coord(2929, 10960, 14) 27 | */ 28 | var t : Transformation = new Transformation(1449749.02835779, -2150945.931013119, 4632165.032378035, 29 | -2162454.5923735118, -1441023.4254683803, -3581364.9874006994); 30 | 31 | __projection = new MercatorProjection(14, t); 32 | } 33 | 34 | override public function toString() : String 35 | { 36 | return "AC_TRANSIT"; 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /docs/com/modestmaps/mapproviders/yahoo/class-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.modestmaps.mapproviders.yahoo - API Documentation 6 | 7 | 8 | 9 | 10 | 11 |

12 | Package com.modestmaps.mapproviders.yahoo 13 |

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
Classes
YahooAerialMapProvider
YahooHybridMapProvider
YahooOverlayMapProvider
YahooRoadMapProvider
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /com/modestmaps/extras/KeyHandler.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.extras; 2 | 3 | import com.modestmaps.Map; 4 | import openfl.events.Event; 5 | import openfl.events.KeyboardEvent; 6 | import openfl.events.MouseEvent; 7 | import openfl.ui.Keyboard; 8 | 9 | 10 | class KeyHandler 11 | { 12 | public var map : Map; 13 | 14 | public function new(map : Map) 15 | { 16 | this.map = map; 17 | map.grid.addEventListener(MouseEvent.CLICK, onClick, false, 0, true); 18 | map.grid.addEventListener(KeyboardEvent.KEY_UP, onKey, false, 0, true); 19 | } 20 | 21 | public function onKey(event : KeyboardEvent) : Void 22 | { 23 | if (event.keyCode == Keyboard.LEFT) 24 | { 25 | map.panLeft(); 26 | } 27 | else if (event.keyCode == Keyboard.RIGHT) 28 | { 29 | map.panRight(); 30 | } 31 | else if (event.keyCode == Keyboard.UP) 32 | { 33 | map.panUp(); 34 | } 35 | else if (event.keyCode == Keyboard.DOWN) 36 | { 37 | map.panDown(); 38 | } 39 | else { 40 | var char : String = String.fromCharCode(event.charCode); 41 | if (char == "+") 42 | { 43 | map.zoomIn(); 44 | } 45 | else if (char == "-") 46 | { 47 | map.zoomOut(); 48 | } 49 | } 50 | } 51 | 52 | public function onClick(event : Event) : Void 53 | { 54 | map.grid.focusRect = false; 55 | map.stage.focus = map.grid; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /docs/com/modestmaps/mapproviders/microsoft/class-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.modestmaps.mapproviders.microsoft - API Documentation 6 | 7 | 8 | 9 | 10 | 11 |

12 | Package com.modestmaps.mapproviders.microsoft 13 |

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
Classes
MicrosoftAerialMapProvider
MicrosoftHybridMapProvider
MicrosoftProvider
MicrosoftRoadMapProvider
31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /com/modestmaps/overlays/PolygonClip.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.overlays; 2 | 3 | import com.modestmaps.Map; 4 | import openfl.display.DisplayObject; 5 | import openfl.geom.Rectangle; 6 | 7 | 8 | /** 9 | * PolygonClip extends MarkerClip to take the bounds of the marker into account when showing/hiding, 10 | * and to trigger a redraw of content that needs scaling. 11 | * 12 | * To trigger the redraw, markers must implement the Redrawable interface provided in this package. 13 | * 14 | * See PolygonMarker for an example, but if you need multi-geometries, complex styling, holes etc., 15 | * you'll need to write your own for the moment. 16 | * 17 | */ 18 | class PolygonClip extends MarkerClip 19 | { 20 | public function new(map : Map) 21 | { 22 | super(map); 23 | this.scaleZoom = true; 24 | this.markerSortFunction = null; 25 | } 26 | 27 | override private function markerInBounds(marker : DisplayObject, w : Float, h : Float) : Bool 28 | { 29 | var rect : Rectangle = new Rectangle(-w, -h, w * 3, h * 3); 30 | return rect.intersects(marker.getBounds(map)); 31 | } 32 | 33 | override public function updateClip(marker : DisplayObject) : Bool 34 | { 35 | // we need to redraw this marker before MarkerClip.updateClip so that markerInBounds will be correct 36 | if (Std.is(marker, Redrawable)) 37 | { 38 | cast((marker), Redrawable).redraw(); 39 | } 40 | return super.updateClip(marker); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /com/modestmaps/geo/Transformation.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | */ 4 | 5 | package com.modestmaps.geo; 6 | 7 | import openfl.geom.Point; 8 | 9 | class Transformation 10 | { 11 | private var ax : Float; 12 | private var bx : Float; 13 | private var cx : Float; 14 | private var ay : Float; 15 | private var by : Float; 16 | private var cy : Float; 17 | 18 | /** 19 | * equivalent to "new flash.geom.Matrix(ax,bx,ay,by,cy,cx)" 20 | */ 21 | public function new(ax : Float, bx : Float, cx : Float, ay : Float, by : Float, cy : Float) 22 | { 23 | this.ax = ax; 24 | this.bx = bx; 25 | this.cx = cx; 26 | this.ay = ay; 27 | this.by = by; 28 | this.cy = cy; 29 | } 30 | 31 | /** 32 | * String signature of the current transformation. 33 | */ 34 | public function toString() : String 35 | { 36 | return "T([" + ax + "," + bx + "," + cx + "][" + ay + "," + by + "," + cy + "])"; 37 | } 38 | 39 | /** 40 | * Transform a point. 41 | */ 42 | public function transform(point : Point) : Point 43 | { 44 | return new Point(ax * point.x + bx * point.y + cx, 45 | ay * point.x + by * point.y + cy); 46 | } 47 | 48 | /** 49 | * Inverse of transform; p = untransform(transform(p)) 50 | */ 51 | public function untransform(point : Point) : Point 52 | { 53 | return new Point((point.x * by - point.y * bx - cx * by + cy * bx) / (ax * by - ay * bx), 54 | (point.x * ay - point.y * ax - cx * ay + cy * ax) / (bx * ay - by * ax)); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /samples/ModestMapsSample/src/SampleMarker.hx: -------------------------------------------------------------------------------- 1 | import openfl.display.Sprite; 2 | import openfl.events.MouseEvent; 3 | import openfl.filters.DropShadowFilter; 4 | 5 | class SampleMarker extends Sprite 6 | { 7 | public var title(get, set) : String; 8 | private var _title : String; 9 | public function new() 10 | { 11 | super(); 12 | buttonMode = true; 13 | mouseChildren = false; 14 | tabEnabled = false; 15 | #if flash 16 | cacheAsBitmap = true; 17 | #end 18 | mouseEnabled = true; 19 | // David's Flash example draws the marker 20 | // in the Flash environment 21 | // but need to draw something: 22 | // first a zero-alpha circle so the filter's bitmap cache doesn't mess things up 23 | graphics.beginFill(0xff0000, 0); 24 | graphics.drawCircle(0, 0, 11); 25 | graphics.endFill(); 26 | // now a red circle 27 | graphics.beginFill(0xff0000); 28 | graphics.drawCircle(0, 0, 10); 29 | graphics.endFill(); 30 | 31 | filters = [new DropShadowFilter()]; 32 | addEventListener(MouseEvent.MOUSE_OVER, mouseOver); 33 | } 34 | private function get_title() : String 35 | { 36 | 37 | return _title; 38 | } 39 | private function set_title(s : String) : String 40 | { 41 | _title = s; 42 | return s; 43 | } 44 | private function mouseOver(e : MouseEvent) : Void 45 | { 46 | parent.swapChildrenAt(parent.getChildIndex(this), parent.numChildren - 1); 47 | } 48 | override public function toString() : String 49 | { 50 | return "[SampleMarker] " + title; 51 | } 52 | } -------------------------------------------------------------------------------- /com/modestmaps/core/painter/TileQueue.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.core.painter; 2 | 3 | import com.modestmaps.core.Tile; 4 | 5 | class TileQueue 6 | { 7 | public var length(get, never) : Int; 8 | 9 | // Tiles we want to load: 10 | private var queue : Array; 11 | 12 | public function new() 13 | { 14 | queue = []; 15 | } 16 | 17 | private function get_length() : Int 18 | { 19 | return queue.length; 20 | } 21 | 22 | public function contains(tile : Tile) : Bool 23 | { 24 | //return Lambda.indexOf(queue, tile) >= 0; 25 | return queue.indexOf(tile) >= 0; 26 | } 27 | 28 | public function remove(tile : Tile) : Void 29 | { 30 | var index : Int = queue.indexOf(tile); 31 | if (index >= 0) 32 | { 33 | queue.splice(index, 1); 34 | } 35 | } 36 | 37 | public function push(tile : Tile) : Void 38 | { 39 | queue.push(tile); 40 | } 41 | 42 | public function shift() : Tile 43 | { 44 | return queue.shift(); 45 | } 46 | 47 | public function sortTiles(callback : Dynamic) : Void 48 | { 49 | queue.sort(callback); 50 | } 51 | 52 | public function retainAll(tiles : Array) : Array 53 | { 54 | var removed : Array = []; 55 | var i : Int = queue.length - 1; 56 | while (i >= 0) 57 | { 58 | var tile : Tile = queue[i]; 59 | if (tiles.indexOf(tile)<0) 60 | { 61 | removed.push(tile); 62 | queue.splice(i, 1); 63 | } 64 | i--; 65 | } 66 | return removed; 67 | } 68 | 69 | public function clear() : Void 70 | { 71 | queue = []; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /docs/com/modestmaps/overlays/class-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.modestmaps.overlays - API Documentation 6 | 7 | 8 | 9 | 10 | 11 |

12 | Package com.modestmaps.overlays 13 |

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |
Interfaces
Redrawable
 
Classes
MarkerClip
PolygonClip
PolygonMarker
Polyline
PolylineClip
43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/IMapProvider.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | */ 4 | 5 | package com.modestmaps.mapproviders; 6 | 7 | import com.modestmaps.core.Coordinate; 8 | import com.modestmaps.geo.Location; 9 | 10 | interface IMapProvider 11 | { 12 | 13 | var tileWidth(get, never) : Int; 14 | 15 | var tileHeight(get, never) : Int; 16 | 17 | /** 18 | * @return an array of Strings urls (or URLRequests) for the images needed for this tile coordinate. 19 | */ 20 | function getTileUrls(coord : Coordinate) : Array; 21 | 22 | /** 23 | * @return projected and transformed coordinate for a location. 24 | */ 25 | function locationCoordinate(location : Location) : Coordinate; 26 | 27 | /** 28 | * @return untransformed and unprojected location for a coordinate. 29 | */ 30 | function coordinateLocation(coordinate : Coordinate) : Location; 31 | 32 | /** 33 | * Get top left outer-zoom limit and bottom right inner-zoom limits, 34 | * as Coordinates in a two element array. 35 | */ 36 | function outerLimits() : Array; 37 | 38 | /** 39 | * A string which describes the projection and transformation of a map provider. 40 | */ 41 | function geometry() : String; 42 | 43 | function toString() : String; 44 | 45 | /** 46 | * Munge coordinate for purposes of image selection and marker containment. 47 | * E.g., useful for cylindical projections with infinite horizontal scroll. 48 | */ 49 | function sourceCoordinate(coord : Coordinate) : Coordinate; 50 | } 51 | -------------------------------------------------------------------------------- /docs/com/modestmaps/geo/class-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.modestmaps.geo - API Documentation 6 | 7 | 8 | 9 | 10 | 11 |

12 | Package com.modestmaps.geo 13 |

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |
Interfaces
IProjection
 
Classes
AbstractProjection
LinearProjection
Location
MercatorProjection
Transformation
43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /com/modestmaps/extras/Distance.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.extras; 2 | 3 | import com.modestmaps.geo.Location; 4 | 5 | class Distance 6 | { 7 | public static inline var R_MILES : Float = 3963.1; 8 | public static inline var R_NAUTICAL_MILES : Float = 3443.9; 9 | public static inline var R_KM : Float = 6378; 10 | public static inline var R_METERS : Float = 6378000; 11 | 12 | /** 13 | *

you can specify different units by optionally providing the 14 | * earth's radius in the units you desire

15 | * 16 | *

Default is 6,378,000 metres, suggested values are:

17 | *
    18 | *
  • 3963.1 statute miles
  • 19 | *
  • 3443.9 nautical miles
  • 20 | *
  • 6378 km
  • 21 | *
22 | * 23 | * @return distance between given start and end locations in metres 24 | * 25 | * @see http://jan.ucc.nau.edu/~cvm/latlon_formula.html 26 | * */ 27 | public static function approxDistance(start : Location, end : Location, r : Float = R_METERS) : Float 28 | { 29 | 30 | var a1 : Float = radians(start.lat); 31 | var b1 : Float = radians(start.lon); 32 | var a2 : Float = radians(end.lat); 33 | var b2 : Float = radians(end.lon); 34 | 35 | var d : Float; 36 | 37 | d = Math.acos(Math.cos(a1) * Math.cos(b1) * Math.cos(a2) * Math.cos(b2) + Math.cos(a1) * Math.sin(b1) * Math.cos(a2) * Math.sin(b2) + Math.sin(a1) * Math.sin(a2)) * r; 38 | return d; 39 | } 40 | 41 | private static function radians(degrees : Float) : Float 42 | { 43 | return degrees * Math.PI / 180.0; 44 | } 45 | 46 | public function new() 47 | { 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/CloudMadeProvider.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.mapproviders; 2 | 3 | import com.modestmaps.core.Coordinate; 4 | import com.modestmaps.mapproviders.OpenStreetMapProvider; 5 | 6 | 7 | class CloudMadeProvider extends OpenStreetMapProvider 8 | { 9 | public static inline var THE_ORIGINAL : String = "1"; 10 | public static inline var FINE_LINE : String = "2"; 11 | public static inline var TOURIST : String = "7"; 12 | 13 | public static inline var FRESH : String = "997"; 14 | public static inline var PALE_DAWN : String = "998"; 15 | public static inline var MIDNIGHT_COMMANDER : String = "999"; 16 | 17 | /** see http://developers.cloudmade.com/projects to get hold of an API key */ 18 | public var key : String; 19 | 20 | /** use the constants above or see maps.cloudmade.com for more styles */ 21 | public var style : String; 22 | 23 | public function new(key : String, style : String = "1") 24 | { 25 | super(); 26 | this.key = key; 27 | this.style = style; 28 | } 29 | 30 | override public function getTileUrls(coord : Coordinate) : Array 31 | { 32 | var worldSize : Int = Math.pow(2, coord.zoom); 33 | if (coord.row < 0 || coord.row >= worldSize) 34 | { 35 | return []; 36 | } 37 | coord = sourceCoordinate(coord); 38 | var server : String = ["a.", "b.", "c.", ""][as3hx.Compat.parseInt(worldSize * coord.row + coord.column) % 4]; 39 | var url : String = "http://" + server + "tile.cloudmade.com/" + [key, style, tileWidth, coord.zoom, coord.column, coord.row].join("/") + ".png"; 40 | return [url]; 41 | } 42 | 43 | override public function toString() : String 44 | { 45 | return "CLOUDMADE"; 46 | } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /com/modestmaps/geo/Location.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | */ 4 | 5 | package com.modestmaps.geo; 6 | 7 | class Location 8 | { 9 | public static inline var MAX_LAT : Float = 84; 10 | public static var MIN_LAT : Float = -MAX_LAT; 11 | public static inline var MAX_LON : Float = 180; 12 | public static var MIN_LON : Float = -MAX_LON; 13 | 14 | // Latitude, longitude, _IN DEGREES_. 15 | public var lat : Float; 16 | public var lon : Float; 17 | 18 | public static function fromString(str : String, lonlat : Bool = false) : Location 19 | { 20 | var parts : Array = str.split(","); 21 | if (lonlat) 22 | { 23 | parts.reverse(); 24 | } 25 | return new Location(Std.parseFloat(parts[0]), Std.parseFloat(parts[1])); 26 | } 27 | 28 | public function new(lat : Float, lon : Float) 29 | { 30 | this.lat = lat; 31 | this.lon = lon; 32 | } 33 | 34 | public function equals(loc : Location) : Bool 35 | { 36 | return loc!=null && loc.lat == lat && loc.lon == lon; 37 | } 38 | 39 | public function clone() : Location 40 | { 41 | return new Location(lat, lon); 42 | } 43 | 44 | /** 45 | * This function normalizes latitude and longitude values to a sensible range 46 | * (±84°N, ±180°E), and returns a new Location instance. 47 | */ 48 | public function normalize() : Location 49 | { 50 | var loc : Location = clone(); 51 | loc.lat = Math.max(MIN_LAT, Math.min(MAX_LAT, loc.lat)); 52 | while (loc.lon > 180)loc.lon -= 360; 53 | while (loc.lon < -180)loc.lon += 360; 54 | return loc; 55 | } 56 | 57 | public function toString(precision : Int = 5) : String 58 | { 59 | //todo return [lat.toFixed(precision), lon.toFixed(precision)].join(","); 60 | return [lat, lon].join(","); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /docs/com/modestmaps/mapproviders/class-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.modestmaps.mapproviders - API Documentation 6 | 7 | 8 | 9 | 10 | 11 |

12 | Package com.modestmaps.mapproviders 13 |

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
Interfaces
IMapProvider
 
Classes
AbstractMapProvider
AbstractZoomifyMapProvider
ACTransitMapProvider
BlueMarbleMapProvider
DailyPlanetProvider
OpenStreetMapProvider
46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /com/modestmaps/overlays/Polyline.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.overlays; 2 | 3 | /** 4 | * Polyline class that takes polyline data and draws it in the given style. 5 | * 6 | * Polylines can be added using: 7 | * 8 | *
 9 | 	 *  var polylineClip:PolylineClip = new PolylineClip(map);
10 | 	 *  map.addChild(polylineClip);
11 | 	 *
12 | 	 *  var polyline:Polyline = new Polyline('poly-id-1', [ new Location(10,10), new Location (20,20) ]);
13 | 	 *  polylineClip.addPolyline(polyline);
14 | 	 * 
15 | * 16 | * @see PolylineClip 17 | * 18 | * Originally contributed by simonoliver. 19 | * 20 | */ 21 | class Polyline 22 | { 23 | public var id : String; 24 | public var locationsArray : Array; 25 | public var lineThickness : Float; 26 | public var lineColor : Float; 27 | public var lineAlpha : Float; 28 | public var pixelHinting : Bool; 29 | public var scaleMode : String; 30 | public var caps : String; 31 | public var joints : String; 32 | public var miterLimit : Float; 33 | 34 | public function new(id : String, 35 | locationsArray : Array, 36 | lineThickness : Float = 3, 37 | lineColor : Float = 0xFF0000, 38 | lineAlpha : Float = 1, 39 | pixelHinting : Bool = false, 40 | scaleMode : String = "normal", 41 | caps : String = null, 42 | joints : String = null, 43 | miterLimit : Float = 3) 44 | { 45 | this.id = id; 46 | this.locationsArray = locationsArray; 47 | this.lineThickness = lineThickness; 48 | this.lineColor = lineColor; 49 | this.lineAlpha = lineAlpha; 50 | this.pixelHinting = pixelHinting; 51 | this.scaleMode = scaleMode; 52 | this.caps = caps; 53 | this.joints = joints; 54 | this.miterLimit = miterLimit; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /samples/old_ModestMapsExamples/src/HelloMap.hx: -------------------------------------------------------------------------------- 1 | 2 | import com.adobe.viewsource.ViewSource; 3 | import com.modestmaps.TweenMap; 4 | import com.modestmaps.extras.MapControls; 5 | import com.modestmaps.extras.MapCopyright; 6 | import com.modestmaps.extras.ZoomSlider; 7 | import com.modestmaps.mapproviders.BlueMarbleMapProvider; 8 | import com.pixelbreaker.ui.osx.MacMouseWheel; 9 | 10 | import flash.display.Sprite; 11 | import flash.display.StageAlign; 12 | import flash.display.StageScaleMode; 13 | import flash.events.Event; 14 | import flash.events.MouseEvent; 15 | 16 | @:meta(SWF(backgroundColor="#ffffff")) 17 | 18 | class HelloMap extends Sprite 19 | { 20 | public var map : TweenMap; 21 | 22 | public function new() 23 | { 24 | super(); 25 | stage.align = StageAlign.TOP_LEFT; 26 | stage.scaleMode = StageScaleMode.NO_SCALE; 27 | 28 | MacMouseWheel.setup(stage); 29 | 30 | ViewSource.addMenuItem(this, "srcview/index.html", true); 31 | 32 | map = new TweenMap(stage.stageWidth, stage.stageHeight, true, new BlueMarbleMapProvider()); 33 | map.addEventListener(MouseEvent.DOUBLE_CLICK, map.onDoubleClick); 34 | map.addEventListener(MouseEvent.MOUSE_WHEEL, map.onMouseWheel); 35 | addChild(map); 36 | 37 | map.addChild(new MapControls(map)); 38 | map.addChild(new ZoomSlider(map)); 39 | map.addChild(new MapCopyright(map)); 40 | 41 | // make sure the map fills the screen: 42 | stage.addEventListener(Event.RESIZE, onStageResize); 43 | } 44 | 45 | public function onStageResize(event : Event) : Void 46 | { 47 | map.setSize(stage.stageWidth, stage.stageHeight); 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /docs/com/modestmaps/extras/class-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.modestmaps.extras - API Documentation 6 | 7 | 8 | 9 | 10 | 11 |

12 | Package com.modestmaps.extras 13 |

14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
Classes
Distance
GreatCircleOverlay
HandCursor
LineStyle
MapControls
MapCopyright
MapScale
NavigatorWindow
Overlay
VirtualEarthCopyright
ZoomBox
ZoomSlider
55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /com/modestmaps/core/painter/TilePool.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.core.painter; 2 | 3 | //import com.modestmaps.core.painter.TileClass; 4 | 5 | import com.modestmaps.core.Tile; 6 | import com.modestmaps.core.TweenTile; 7 | 8 | /** 9 | * This post http://lab.polygonal.de/2008/06/18/using-object-pools/ 10 | * suggests that using Object pools, especially for complex classes like Sprite 11 | * is a lot faster than calling new Object(). The suggested implementation 12 | * uses a linked list, but to get started with it here I'm using an Array. 13 | * 14 | * If anyone wants to try it with a linked list and compare the times, 15 | * it seems like it could be worth it :) 16 | */ 17 | class TilePool 18 | { 19 | private static inline var MIN_POOL_SIZE : Int = 256; 20 | private static inline var MAX_NEW_TILES : Int = 256; 21 | 22 | private var pool : Array = []; 23 | private var isTweenTile : Bool; 24 | 25 | public function new() 26 | { 27 | //let's make the TweenTile bu default. 28 | this.isTweenTile = true; 29 | } 30 | 31 | public function setTileClass(isTweenTile: Bool) : Void 32 | { 33 | this.isTweenTile = isTweenTile; 34 | pool = []; 35 | } 36 | 37 | public function getTile(column : Int, row : Int, zoom : Int) : Tile 38 | { 39 | if (pool.length < MIN_POOL_SIZE) 40 | { 41 | if (isTweenTile) 42 | { 43 | while (pool.length < MAX_NEW_TILES) 44 | { 45 | pool.push(new TweenTile(0,0,0)); 46 | } 47 | } 48 | else 49 | { 50 | while (pool.length < MAX_NEW_TILES) 51 | { 52 | pool.push(new Tile(0,0,0)); 53 | } 54 | } 55 | } 56 | var tile : Tile = pool.pop(); 57 | tile.init(column, row, zoom); 58 | return tile; 59 | } 60 | 61 | public function returnTile(tile : Tile) : Void 62 | { 63 | tile.destroy(); 64 | pool.push(tile); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /com/modestmaps/core/painter/TileCache.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.core.painter; 2 | 3 | import com.modestmaps.core.Tile; 4 | import com.modestmaps.core.painter.TilePool; 5 | import haxe.ds.StringMap; 6 | 7 | 8 | /** the alreadySeen Dictionary here will contain up to grid.maxTilesToKeep Tiles */ 9 | class TileCache 10 | { 11 | public var size(get, never) : Int; 12 | 13 | // Tiles we've already seen and fully loaded, by key (.name) 14 | private var alreadySeen:StringMap; 15 | private var tilePool : TilePool; // for handing tiles back! 16 | 17 | public function new(tilePool : TilePool) 18 | { 19 | this.tilePool = tilePool; 20 | alreadySeen = new StringMap(); 21 | } 22 | 23 | private function get_size() : Int 24 | { 25 | var alreadySeenCount : Int = 0; 26 | 27 | for (key in alreadySeen) 28 | { 29 | alreadySeenCount++; 30 | } 31 | return alreadySeenCount; 32 | } 33 | 34 | public function putTile(tile : Tile) : Void 35 | { 36 | alreadySeen.set(tile.name,tile); 37 | } 38 | 39 | public function getTile(key : String) : Tile 40 | { 41 | return alreadySeen.get(key); 42 | } 43 | 44 | public function containsKey(key : String) : Bool 45 | { 46 | return alreadySeen.exists(key); 47 | } 48 | 49 | public function retainKeys(keys : Array) : Void 50 | { 51 | // loop over our internal tile cache 52 | // and throw out tiles not in recentlySeen 53 | for (key in alreadySeen.keys()) 54 | { 55 | if (keys.indexOf(key) < 0) 56 | { 57 | tilePool.returnTile(alreadySeen.get(key)); 58 | alreadySeen.remove(key); 59 | } 60 | } 61 | } 62 | 63 | public function clear() : Void 64 | { 65 | for (key in alreadySeen.keys()) 66 | { 67 | tilePool.returnTile(alreadySeen.get(key)); 68 | alreadySeen.set(key, null); 69 | alreadySeen.remove(key); 70 | } 71 | alreadySeen = new StringMap(); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /samples/ModestMapsSample/src/Tooltip.hx: -------------------------------------------------------------------------------- 1 | /** 2 | * * @author David Knape 3 | */ 4 | 5 | import openfl.display.Shape; 6 | import openfl.display.Sprite; 7 | import openfl.text.TextField; 8 | import openfl.text.TextFieldAutoSize; 9 | import openfl.text.TextFormat; 10 | class Tooltip extends Sprite 11 | { 12 | public var label(never, set) : String; 13 | public var background : Shape; 14 | public var label_txt : TextField; 15 | public function new() 16 | { 17 | super(); 18 | background = new Shape(); 19 | background.graphics.beginFill(0xffffff); 20 | background.graphics.drawRect(0, 0, 100, 20); 21 | background.graphics.endFill(); 22 | addChild(background); 23 | label_txt = new TextField(); 24 | label_txt.selectable = false; 25 | label_txt.defaultTextFormat = new TextFormat("Verdana", 10, 0x000000); 26 | addChild(label_txt); 27 | visible = false; 28 | mouseEnabled = false; 29 | } 30 | private function set_label(s : String) : String 31 | { 32 | label_txt.autoSize = TextFieldAutoSize.LEFT; 33 | label_txt.width = 200; 34 | label_txt.multiline = label_txt.wordWrap = true; 35 | label_txt.text = s; 36 | background.width = Math.max(100, label_txt.textWidth + 10); 37 | background.height = label_txt.textHeight + 18; 38 | background.y = Math.round( -background.height - 16); 39 | background.x = 1; 40 | label_txt.y = background.y + 2; 41 | graphics.clear(); 42 | graphics.lineStyle(0, 0x000000); 43 | graphics.beginFill(0xffffff); 44 | graphics.moveTo(0, 0); 45 | graphics.lineTo(background.x - 1, background.y + background.height + 1); 46 | graphics.lineTo(background.x - 1, background.y - 1); 47 | graphics.lineTo(background.x + background.width + 1, background.y - 1); 48 | graphics.lineTo(background.x + background.width + 1, background.y + background.height + 1); 49 | graphics.lineTo(background.x + 10, background.y + background.height + 1); 50 | graphics.lineTo(0, 0); 51 | return s; 52 | } 53 | } -------------------------------------------------------------------------------- /com/modestmaps/extras/VirtualEarthCopyright.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.extras; 2 | 3 | import com.modestmaps.Map; 4 | import com.modestmaps.events.MapEvent; 5 | import com.modestmaps.extras.MapCopyright; 6 | import com.modestmaps.extras.VirtualEarthLogo; 7 | import openfl.display.Bitmap; 8 | import openfl.filters.GlowFilter; 9 | import openfl.text.AntiAliasType; 10 | import openfl.text.TextFormat; 11 | 12 | 13 | 14 | class VirtualEarthCopyright extends MapCopyright 15 | { 16 | // required by MS to use Flash to show tiles 17 | @:meta(Embed(source="ve_logo.png")) 18 | 19 | public var VirtualEarthLogo : Class; 20 | 21 | public var veLogo : Bitmap; 22 | 23 | public function new(map : Map, offsetX : Float = 10, offsetY : Float = 10) 24 | { 25 | super(map, offsetX, offsetY); 26 | 27 | copyrightField.embedFonts = true; 28 | copyrightField.antiAliasType = AntiAliasType.ADVANCED; 29 | copyrightField.defaultTextFormat = new TextFormat("Helvetica", 10, 0x202020); 30 | copyrightField.wordWrap = false; 31 | copyrightField.selectable = false; 32 | copyrightField.htmlText = "Copyright goes here..."; 33 | copyrightField.width = copyrightField.textWidth + 4; 34 | copyrightField.height = copyrightField.textHeight + 4; 35 | copyrightField.x = map.getWidth() - this.offsetX - copyrightField.width; 36 | copyrightField.y = map.getHeight() - this.offsetY - copyrightField.height; 37 | copyrightField.filters = [new GlowFilter(0xffffff, 0.5, 4, 4, 4)]; 38 | 39 | veLogo = Type.createInstance(VirtualEarthLogo, []); 40 | addChild(veLogo); 41 | 42 | onMapResized(null); 43 | } 44 | 45 | override private function onMapResized(event : MapEvent) : Void 46 | { 47 | copyrightField.x = map.getWidth() - this.offsetX - copyrightField.width; 48 | copyrightField.y = map.getHeight() - this.offsetY - copyrightField.height; 49 | veLogo.x = map.getWidth() - veLogo.width - 10; 50 | veLogo.y = copyrightField.y - veLogo.height - 10; 51 | } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Adobe Flex 2 Language Reference 8 | 9 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | <body> 46 | 47 | <h2>Frame Alert</h2> 48 | 49 | <p> 50 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 51 | <br> 52 | Link to <a href="package-summary.html">Non-frame version.</a> 53 | 54 | </p> 55 | 56 | </body> 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /com/modestmaps/util/BinaryUtil.hx: -------------------------------------------------------------------------------- 1 | /** 2 | * @author darren 3 | * $Id$ 4 | */ 5 | package com.modestmaps.util; 6 | 7 | 8 | class BinaryUtil 9 | { 10 | private static var PADDING:String = "00000000000000000000000000000000"; 11 | 12 | /** 13 | * NB:- don't use int.toString(2) here because it 14 | * doesn't do what we want with negative numbers - which is 15 | * wrap around and pad with 1's. Hence convert to uint first. 16 | * 17 | * @param numberToConvert 18 | * @return 32 digit binary representation (eg : 1011) 19 | */ 20 | public static function convertToBinary(numberToConvert:Int):String 21 | { 22 | var result:String = decimalToBinary(numberToConvert); 23 | if (result.length < 32) 24 | { 25 | result = PADDING.substr(result.length) + result; 26 | } 27 | return result; 28 | } 29 | 30 | /** 31 | * 32 | * @param binaryRepresentation : binary string representation (eg : 1011) 33 | * @return 34 | */ 35 | public static function convertToDecimal(binaryRepresentation:String):Int 36 | { 37 | var result:Int = binaryToDecimal(binaryRepresentation); 38 | return result; 39 | } 40 | 41 | /** 42 | * 43 | * @param decimalValue 44 | * @return 45 | */ 46 | private static function decimalToBinary(decimalValue:Int):String 47 | { 48 | var stringBinary:Dynamic = decimalValue; 49 | var result:String = stringBinary.toString(); 50 | return result; 51 | } 52 | 53 | /** 54 | * 55 | * @param binaryRepresentation 56 | * @return 57 | */ 58 | private static function binaryToDecimal(binaryRepresentation:String):Int 59 | { 60 | var result : Float = 0; 61 | for (i in 0 ... binaryRepresentation.length) 62 | { 63 | if (binaryRepresentation.charAt(i) == '1') 64 | { 65 | result = result + Math.pow(2, binaryRepresentation.length - 1 - i); 66 | } 67 | } 68 | return Std.int(result); 69 | } 70 | 71 | /** 72 | * 73 | * @param binaryRepresentation 74 | * @return 75 | */ 76 | private static function binaryToHexadecimal(binaryRepresentation:String):String 77 | { 78 | var binaryToIntRepresentation : Int = binaryToDecimal(binaryRepresentation); 79 | return '0x' + StringTools.hex(binaryToIntRepresentation); 80 | } 81 | 82 | } -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/CartoDBProvider.hx: -------------------------------------------------------------------------------- 1 | /** 2 | * MapProvider for Carto 3 | * 4 | * @author Marc Mauri 5 | * $Id$ 6 | */ 7 | package com.modestmaps.mapproviders; 8 | 9 | import com.modestmaps.core.Coordinate; 10 | enum CARTODB_MAPTYPE 11 | { 12 | POSITRON; 13 | DARK_MATTER; 14 | } 15 | 16 | class CartoDBProvider extends AbstractMapProvider implements IMapProvider 17 | { 18 | private var baseURL:String; 19 | private var retinaDisplay:Bool; 20 | 21 | public function new(MapType:CARTODB_MAPTYPE, useSSL:Bool = false, retinaDisplay:Bool = false, 22 | minZoom : Int = AbstractMapProvider.MIN_ZOOM, maxZoom : Int = AbstractMapProvider.MAX_ZOOM) 23 | { 24 | super(minZoom, maxZoom); 25 | if (useSSL) 26 | { 27 | baseURL = 'https://cartodb-basemaps-@S.global.ssl.fastly.net/'; 28 | } 29 | else 30 | { 31 | baseURL = 'http://@S.basemaps.cartocdn.com/'; 32 | } 33 | 34 | switch (MapType) 35 | { 36 | case POSITRON : baseURL += "light_all" + "/"; 37 | case DARK_MATTER: baseURL += "dark_all" +"/"; 38 | } 39 | this.retinaDisplay = retinaDisplay; 40 | //todo _attribution = "©OpenStreetMap contributors, ©CartoDB"; 41 | //todo crossdomain 42 | } 43 | 44 | public function toString() : String 45 | { 46 | return "CARTODB"; 47 | } 48 | 49 | public function getTileUrls(coord : Coordinate) : Array 50 | { 51 | var sourceCoord : Coordinate = sourceCoordinate(coord); 52 | if (sourceCoord.row < 0 || sourceCoord.row >= Math.pow(2, coord.zoom)) 53 | { 54 | return []; 55 | } 56 | 57 | var server : String = ["a", "b", "c", "d"][Math.floor(sourceCoord.row + sourceCoord.column + sourceCoord.zoom) % 4]; 58 | var finalurl:String; 59 | if (retinaDisplay) 60 | { 61 | finalurl = StringTools.replace(baseURL, "@S", server) + [sourceCoord.zoom, sourceCoord.column, sourceCoord.row ].join('/') + '@2x.png'; 62 | } 63 | else { 64 | finalurl = StringTools.replace(baseURL, "@S", server) + [sourceCoord.zoom, sourceCoord.column, sourceCoord.row ].join('/') + '.png'; 65 | } 66 | return [finalurl]; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /docs/index-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Adobe Flex 2 Language Reference 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |

Index

19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 |
AN
BO
CP
DQ
ER
FS
GT
HU
IV
JW
KX
LY
MZ
117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /com/modestmaps/core/Coordinate.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | */ 4 | 5 | package com.modestmaps.core; 6 | 7 | class Coordinate 8 | { 9 | public var row : Float; 10 | public var column : Float; 11 | public var zoom : Float; 12 | 13 | public function new(row : Float, column : Float, zoom : Float) 14 | { 15 | this.row = row; 16 | this.column = column; 17 | this.zoom = zoom; 18 | } 19 | 20 | public function toString() : String 21 | { 22 | return "(" + row + "," + column + " @" + zoom + ")"; 23 | } 24 | 25 | public function copy() : Coordinate 26 | { 27 | return new Coordinate(row, column, zoom); 28 | } 29 | 30 | /** 31 | * Return a new coordinate that corresponds to that of the tile containing this one 32 | */ 33 | public function container() : Coordinate 34 | { 35 | return new Coordinate(Math.floor(row), Math.floor(column), zoom); 36 | } 37 | 38 | public function zoomTo(destination : Float) : Coordinate 39 | { 40 | return new Coordinate(row * Math.pow(2, destination - zoom), 41 | column * Math.pow(2, destination - zoom), 42 | destination); 43 | } 44 | 45 | public function zoomBy(distance : Float) : Coordinate 46 | { 47 | return new Coordinate(row * Math.pow(2, distance), 48 | column * Math.pow(2, distance), 49 | zoom + distance); 50 | } 51 | 52 | public function isRowEdge() : Bool 53 | { 54 | return Math.round(row) == row; 55 | } 56 | 57 | public function isColumnEdge() : Bool 58 | { 59 | return Math.round(column) == column; 60 | } 61 | 62 | public function isEdge() : Bool 63 | { 64 | return isRowEdge() && isColumnEdge(); 65 | } 66 | 67 | public function up(distance : Float = 1) : Coordinate 68 | { 69 | return new Coordinate(row - distance, column, zoom); 70 | } 71 | 72 | public function right(distance : Float = 1) : Coordinate 73 | { 74 | return new Coordinate(row, column + distance, zoom); 75 | } 76 | 77 | public function down(distance : Float = 1) : Coordinate 78 | { 79 | return new Coordinate(row + distance, column, zoom); 80 | } 81 | 82 | public function left(distance : Float = 1) : Coordinate 83 | { 84 | return new Coordinate(row, column - distance, zoom); 85 | } 86 | 87 | /** 88 | * Returns true if the the two coordinates refer to the same Tile location. 89 | */ 90 | public function equalTo(coord : Coordinate) : Bool 91 | { 92 | return (coord !=null && coord.row == this.row && coord.column == this.column && coord.zoom == this.zoom); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /samples/old_ModestMapsExamples/src/HelloPolygons.hx: -------------------------------------------------------------------------------- 1 | 2 | import com.adobe.viewsource.ViewSource; 3 | import com.modestmaps.TweenMap; 4 | import com.modestmaps.core.MapExtent; 5 | import com.modestmaps.extras.MapControls; 6 | import com.modestmaps.extras.MapCopyright; 7 | import com.modestmaps.extras.ZoomSlider; 8 | import com.modestmaps.geo.Location; 9 | import com.modestmaps.mapproviders.BlueMarbleMapProvider; 10 | import com.modestmaps.overlays.PolygonClip; 11 | import com.modestmaps.overlays.PolygonMarker; 12 | import com.pixelbreaker.ui.osx.MacMouseWheel; 13 | 14 | import flash.display.Sprite; 15 | import flash.display.StageAlign; 16 | import flash.display.StageScaleMode; 17 | import flash.events.Event; 18 | import flash.events.MouseEvent; 19 | 20 | @:meta(SWF(backgroundColor="#ffffff")) 21 | 22 | class HelloPolygons extends Sprite 23 | { 24 | public var map : TweenMap; 25 | 26 | public function new() 27 | { 28 | super(); 29 | stage.align = StageAlign.TOP_LEFT; 30 | stage.scaleMode = StageScaleMode.NO_SCALE; 31 | 32 | MacMouseWheel.setup(stage); 33 | 34 | ViewSource.addMenuItem(this, "srcview/index.html", true); 35 | 36 | map = new TweenMap(stage.stageWidth, stage.stageHeight, true, new BlueMarbleMapProvider()); 37 | map.addEventListener(MouseEvent.DOUBLE_CLICK, map.onDoubleClick); 38 | map.addEventListener(MouseEvent.MOUSE_WHEEL, map.onMouseWheel); 39 | addChild(map); 40 | 41 | var polygonClip : PolygonClip = new PolygonClip(map); 42 | 43 | var locations : Array = [new Location(37.83435, 21.36860), 44 | new Location(37.83435, 21.58489), 45 | new Location(37.78105, 21.58489), 46 | new Location(37.78105, 21.36860)]; 47 | 48 | var polygon : PolygonMarker = new PolygonMarker(map, locations, true); 49 | 50 | polygonClip.attachMarker(polygon, polygon.location); 51 | 52 | map.addChild(polygonClip); 53 | 54 | map.setExtent(MapExtent.fromLocations(locations)); 55 | 56 | map.addChild(new MapControls(map)); 57 | map.addChild(new ZoomSlider(map)); 58 | map.addChild(new MapCopyright(map)); 59 | 60 | // make sure the map fills the screen: 61 | stage.addEventListener(Event.RESIZE, onStageResize); 62 | } 63 | 64 | public function onStageResize(event : Event) : Void 65 | { 66 | map.setSize(stage.stageWidth, stage.stageHeight); 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /docs/appendixes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Appendixes 8 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 |
32 |
33 |
34 | 35 | 36 | 37 | 38 |
 AppendixDescription
39 |

40 | 42 |
43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /samples/old_ModestMapsExamples/src/HelloExtras.hx: -------------------------------------------------------------------------------- 1 | import nme.errors.Error; 2 | 3 | import com.adobe.viewsource.ViewSource; 4 | import com.modestmaps.TweenMap; 5 | import com.modestmaps.extras.MapControls; 6 | import com.modestmaps.extras.MapCopyright; 7 | import com.modestmaps.extras.MapScale; 8 | import com.modestmaps.extras.NavigatorWindow; 9 | import com.modestmaps.extras.ZoomBox; 10 | import com.modestmaps.extras.ZoomSlider; 11 | import com.modestmaps.mapproviders.OpenStreetMapProvider; 12 | import com.pixelbreaker.ui.osx.MacMouseWheel; 13 | 14 | import flash.display.Sprite; 15 | import flash.display.StageAlign; 16 | import flash.display.StageScaleMode; 17 | import flash.events.Event; 18 | import flash.events.MouseEvent; 19 | 20 | @:meta(SWF(backgroundColor="#ffffff",frameRate="30")) 21 | 22 | class HelloExtras extends Sprite 23 | { 24 | public function new() 25 | { 26 | super(); 27 | stage.align = StageAlign.TOP_LEFT; 28 | stage.scaleMode = StageScaleMode.NO_SCALE; 29 | 30 | // see http://blog.pixelbreaker.com/flash/swfmacmousewheel/ 31 | try{ 32 | MacMouseWheel.setup(stage); 33 | } catch (error : Error){ 34 | trace("NO MAC MOUSEWHEEL SUPPORT!"); 35 | } 36 | 37 | ViewSource.addMenuItem(this, "srcview/index.html", true); 38 | 39 | var map : TweenMap = new TweenMap(stage.stageWidth, stage.stageHeight, true, new OpenStreetMapProvider()); 40 | map.addEventListener(MouseEvent.DOUBLE_CLICK, map.onDoubleClick); 41 | map.addEventListener(MouseEvent.MOUSE_WHEEL, map.onMouseWheel); 42 | addChild(map); 43 | 44 | /* map.grid.maxChildSearch = 1; 45 | map.grid.maxParentSearch = 5; 46 | map.grid.maxParentLoad = 0; 47 | map.grid.maxOpenRequests = 4; 48 | map.grid.tileBuffer = 0; */ 49 | //map.grid.roundPositionsEnabled = true; 50 | //map.grid.roundScalesEnabled = true; 51 | //map.grid.smoothContent = true; 52 | 53 | //map.addChild(map.grid.debugField); 54 | 55 | map.addChild(new MapCopyright(map, 143, 10)); 56 | map.addChild(new ZoomBox(map)); 57 | map.addChild(new ZoomSlider(map)); 58 | map.addChild(new NavigatorWindow(map)); 59 | map.addChild(new MapControls(map, true, true)); 60 | map.addChild(new MapScale(map, 140)); 61 | 62 | stage.addEventListener(Event.RESIZE, function(event : Event) : Void{map.setSize(stage.stageWidth, stage.stageHeight); 63 | }); 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /samples/ModestMapsSample/ModestMapsSample.hxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | "$(CompilerPath)/haxelib" run lime build "$(OutputFile)" $(TargetBuild) -$(BuildConfig) -Dfdb 52 | 53 | 54 | 55 | 56 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /samples/ModestMapsSample/src/MapProviderButton.hx: -------------------------------------------------------------------------------- 1 | /* Button for use in ModestMaps Sample 2 | * 3 | * @author David Knape 4 | */ 5 | import com.modestmaps.mapproviders.IMapProvider; 6 | import openfl.display.Sprite; 7 | import openfl.events.MouseEvent; 8 | import openfl.filters.DropShadowFilter; 9 | import openfl.geom.ColorTransform; 10 | import openfl.text.TextField; 11 | import openfl.text.TextFormat; 12 | 13 | class MapProviderButton extends Sprite 14 | { 15 | public var selected(get, set) : Bool; 16 | private var label : TextField; 17 | public var mapProvider : IMapProvider; 18 | private var overTransform : ColorTransform = new ColorTransform(1, 1, 1); 19 | private var outTransform : ColorTransform = new ColorTransform(1, .9, .6); 20 | private var normalFormat : TextFormat = new TextFormat("Verdana", 10, 0x000000, false); 21 | private var selectedFormat : TextFormat = new TextFormat("Verdana", 10, 0x000000, true); 22 | private var _selected : Bool = false; 23 | 24 | public function new(label_text : String, map_provider : IMapProvider, selected : Bool = false) 25 | { 26 | super(); 27 | useHandCursor = true; 28 | mouseChildren = false; 29 | buttonMode = true; 30 | addEventListener(MouseEvent.MOUSE_OVER, onMouseOver); 31 | addEventListener(MouseEvent.MOUSE_OUT, onMouseOut); 32 | mapProvider = map_provider; 33 | filters = [new DropShadowFilter(1, 45, 0, 1, 3, 3, .7, 2)]; 34 | transform.colorTransform = outTransform; 35 | // create label 36 | label = new TextField(); 37 | label.selectable = false; 38 | label.defaultTextFormat = normalFormat; 39 | label.text = label_text; 40 | label.width = label.textWidth + 8; 41 | label.height = 18; 42 | label.x = label.y = 1; 43 | addChild(label); 44 | this.selected = selected; 45 | // create background 46 | graphics.clear(); 47 | graphics.beginFill(0xdddddd); 48 | graphics.drawRoundRect(0, 0, label.width + 2, 18, 9, 9); 49 | graphics.beginFill(0xffffff); 50 | graphics.drawRoundRect(0, 0, label.width, 16, 9, 9); 51 | graphics.beginFill(0xbbbbbb); 52 | graphics.drawRoundRect(2, 2, label.width, 16, 9, 9); 53 | graphics.beginFill(0xdddddd); 54 | graphics.drawRoundRect(1, 1, label.width, 16, 9, 9); 55 | } 56 | 57 | public function onMouseOver(event : MouseEvent = null) : Void 58 | { 59 | transform.colorTransform = overTransform; 60 | } 61 | 62 | public function onMouseOut(event : MouseEvent = null) : Void 63 | { 64 | transform.colorTransform = outTransform; 65 | } 66 | private function set_selected(s : Bool) : Bool 67 | { 68 | _selected = s; 69 | label.setTextFormat((s) ? selectedFormat : normalFormat); 70 | return s; 71 | } 72 | 73 | private function get_selected() : Bool 74 | { 75 | return _selected; 76 | } 77 | } -------------------------------------------------------------------------------- /samples/old_ModestMapsExamples/src/com/pixelbreaker/ui/osx/MacMouseWheel.hx: -------------------------------------------------------------------------------- 1 | package com.pixelbreaker.ui.osx; 2 | 3 | 4 | import flash.system.Capabilities; 5 | import flash.display.InteractiveObject; 6 | import flash.display.Stage; 7 | import flash.events.MouseEvent; 8 | import flash.external.ExternalInterface; 9 | /** 10 | * @author Gabriel Bucknall 11 | * 12 | * Class that supports using the mouseWheel on Mac OS, requires javascript class 13 | * swfmacmousewheel.js 14 | */ 15 | class MacMouseWheel 16 | { 17 | private static var instance : MacMouseWheel; 18 | 19 | private var _stage : Stage; 20 | private var _currItem : InteractiveObject; 21 | private var _clonedEvent : MouseEvent; 22 | 23 | public static function getInstance() : MacMouseWheel 24 | { 25 | if (instance == null) instance = new MacMouseWheel(new SingletonEnforcer()); 26 | return instance; 27 | } 28 | 29 | public function new(enforcer : SingletonEnforcer) 30 | { 31 | 32 | } 33 | 34 | /* 35 | * Initialize the MacMouseWheel class 36 | * 37 | * @param stage Stage instance e.g DocumentClass.stage 38 | * 39 | */ 40 | public static function setup(stage : Stage) : Void 41 | { 42 | var isMac : Bool = Capabilities.os.toLowerCase().indexOf("mac") != -1; 43 | if (isMac) getInstance()._setup(stage); 44 | } 45 | 46 | private function _setup(stage : Stage) : Void 47 | { 48 | _stage = stage; 49 | _stage.addEventListener(MouseEvent.MOUSE_MOVE, _getItemUnderCursor); 50 | 51 | if (ExternalInterface.available) 52 | { 53 | ExternalInterface.addCallback("externalMouseEvent", _externalMouseEvent); 54 | } 55 | } 56 | 57 | private function _getItemUnderCursor(e : MouseEvent) : Void 58 | { 59 | _currItem = cast((e.target), InteractiveObject); 60 | _clonedEvent = cast((e), MouseEvent); 61 | } 62 | 63 | private function _externalMouseEvent(delta : Float) : Void 64 | { 65 | var wheelEvent : MouseEvent = new MouseEvent( 66 | MouseEvent.MOUSE_WHEEL, 67 | true, 68 | false, 69 | _clonedEvent.localX, 70 | _clonedEvent.localY, 71 | _clonedEvent.relatedObject, 72 | _clonedEvent.ctrlKey, 73 | _clonedEvent.altKey, 74 | _clonedEvent.shiftKey, 75 | _clonedEvent.buttonDown, 76 | as3hx.Compat.parseInt(delta), 77 | ); 78 | _currItem.dispatchEvent(wheelEvent); 79 | } 80 | } 81 | 82 | 83 | class SingletonEnforcer 84 | { 85 | 86 | @:allow(com.pixelbreaker.ui.osx) 87 | private function new() 88 | { 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /docs/print.css: -------------------------------------------------------------------------------- 1 | /* 2 | //////////////////////////////////////////////////////////////////////////////// 3 | // 4 | // ADOBE SYSTEMS INCORPORATED 5 | // Copyright 2005-2007 Adobe Systems Incorporated 6 | // All Rights Reserved. 7 | // 8 | // NOTICE: Adobe permits you to use, modify, and distribute this file 9 | // in accordance with the terms of the license agreement accompanying it. 10 | // 11 | //////////////////////////////////////////////////////////////////////////////// 12 | */ 13 | 14 | body { 15 | color: #000000; 16 | background: #ffffff; 17 | font-family: "Times New Roman", Times, serif; 18 | font-size: 12pt; 19 | } 20 | a { 21 | text-decoration: none; 22 | color: #000000; 23 | } 24 | pre { 25 | white-space: -moz-pre-wrap; /* Mozilla */ 26 | white-space: -pre-wrap; /* Opera 4-6 */ 27 | white-space: -o-pre-wrap; /* Opera 7 */ 28 | word-wrap: break-word; /* IE */ 29 | } 30 | .titleTableTopNav, .titleTableSubNav, .logoImage { 31 | display: none; 32 | } 33 | .packageFrame { 34 | display: none; 35 | } 36 | .titleTableSubTitle { 37 | font-weight: bold; 38 | } 39 | .classHeaderTableLabel { 40 | padding-right: 10px; 41 | vertical-align: top; 42 | } 43 | .showHideLinks { 44 | display: none; 45 | } 46 | html>body code { 47 | font-size: 10pt; 48 | } 49 | .summaryTableTitle, .detailSectionHeader { 50 | font-size: 14pt; 51 | font-weight: bold; 52 | padding-top: 15px; 53 | padding-bottom: 5px; 54 | } 55 | .summaryTable { 56 | border: 1px solid #000000; 57 | border-collapse: collapse; 58 | width: 100%; 59 | } 60 | .summaryTableDescription { 61 | padding-bottom: 20px; 62 | } 63 | .summaryTableSignatureCol, .summaryTableOwnerCol, .summaryTableLastCol, .summaryTableCol { 64 | border: 1px solid #000000; 65 | } 66 | .summaryTablePaddingCol { 67 | border: 1px solid #000000; 68 | border-right: 0px; 69 | } 70 | .summaryTableInheritanceCol, .summaryTableOperatorCol, .summaryTableStatementCol, .summaryTableSecondCol { 71 | border: 1px solid #000000; 72 | border-left: 0px; 73 | } 74 | .summaryTableLastCol { 75 | vertical-align: top; 76 | } 77 | .detailHeader { 78 | font-size: 13pt; 79 | padding-top: 100px; 80 | } 81 | .detailHeaderName { 82 | font-weight: bold; 83 | } 84 | .detailHeaderType { 85 | padding-left: 5px; 86 | } 87 | .detailHeaderRule { 88 | background: #FF0000; 89 | } 90 | .seeAlso { 91 | padding-bottom: 20px; 92 | margin-top: -20px; 93 | } 94 | .innertable { 95 | border-collapse: collapse; 96 | } 97 | .innertable td,.innertable th { 98 | border: 1px solid #000000; 99 | padding-left: 5px; 100 | padding-right: 5px; 101 | } 102 | .listing { 103 | font-size: 10pt; 104 | } 105 | .feedbackLink { 106 | display: none; 107 | } 108 | .copyright { 109 | font-size: 10pt; 110 | } -------------------------------------------------------------------------------- /docs/cookies.js: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // ADOBE SYSTEMS INCORPORATED 4 | // Copyright 2006-2007 Adobe Systems Incorporated 5 | // All Rights Reserved. 6 | // 7 | // NOTICE: Adobe permits you to use, modify, and distribute this file 8 | // in accordance with the terms of the license agreement accompanying it. 9 | // 10 | //////////////////////////////////////////////////////////////////////////////// 11 | 12 | /** 13 | * Read the JavaScript cookies tutorial at: 14 | * http://www.netspade.com/articles/javascript/cookies.xml 15 | */ 16 | 17 | /** 18 | * Sets a Cookie with the given name and value. 19 | * 20 | * name Name of the cookie 21 | * value Value of the cookie 22 | * [expires] Expiration date of the cookie (default: end of current session) 23 | * [path] Path where the cookie is valid (default: path of calling document) 24 | * [domain] Domain where the cookie is valid 25 | * (default: domain of calling document) 26 | * [secure] Boolean value indicating if the cookie transmission requires a 27 | * secure transmission 28 | */ 29 | function setCookie(name, value, expires, path, domain, secure) 30 | { 31 | document.cookie= name + "=" + escape(value) + 32 | ((expires) ? "; expires=" + expires.toGMTString() : "") + 33 | ((path) ? "; path=" + path : "") + 34 | ((domain) ? "; domain=" + domain : "") + 35 | ((secure) ? "; secure" : ""); 36 | } 37 | 38 | /** 39 | * Gets the value of the specified cookie. 40 | * 41 | * name Name of the desired cookie. 42 | * 43 | * Returns a string containing value of specified cookie, 44 | * or null if cookie does not exist. 45 | */ 46 | function getCookie(name) 47 | { 48 | var dc = document.cookie; 49 | var prefix = name + "="; 50 | var begin = dc.indexOf("; " + prefix); 51 | if (begin == -1) 52 | { 53 | begin = dc.indexOf(prefix); 54 | if (begin != 0) return null; 55 | } 56 | else 57 | { 58 | begin += 2; 59 | } 60 | var end = document.cookie.indexOf(";", begin); 61 | if (end == -1) 62 | { 63 | end = dc.length; 64 | } 65 | return unescape(dc.substring(begin + prefix.length, end)); 66 | } 67 | 68 | /** 69 | * Deletes the specified cookie. 70 | * 71 | * name name of the cookie 72 | * [path] path of the cookie (must be same as path used to create cookie) 73 | * [domain] domain of the cookie (must be same as domain used to create cookie) 74 | */ 75 | function deleteCookie(name, path, domain) 76 | { 77 | if (getCookie(name)) 78 | { 79 | document.cookie = name + "=" + 80 | ((path) ? "; path=" + path : "") + 81 | ((domain) ? "; domain=" + domain : "") + 82 | "; expires=Thu, 01-Jan-70 00:00:01 GMT"; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /com/modestmaps/geo/AbstractProjection.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | */ 4 | 5 | package com.modestmaps.geo; 6 | 7 | import com.modestmaps.core.Coordinate; 8 | import com.modestmaps.geo.IProjection; 9 | import com.modestmaps.geo.Location; 10 | import com.modestmaps.geo.Transformation; 11 | import openfl.errors.Error; 12 | import openfl.geom.Point; 13 | 14 | 15 | class AbstractProjection implements IProjection 16 | { 17 | // linear transformation, if any. 18 | private var T : Transformation; 19 | 20 | // required native zoom for which transformation above is valid. 21 | private var zoom : Float; 22 | 23 | public function new(zoom : Float, T : Transformation) 24 | { 25 | // a transformation is not strictly necessary 26 | if (T != null) 27 | this.T = T; 28 | 29 | this.zoom = zoom; 30 | } 31 | 32 | /** 33 | * String signature of the current projection. 34 | */ 35 | public function toString() : String 36 | { 37 | throw new Error("Abstract method not implemented by subclass."); 38 | return null; 39 | } 40 | 41 | /** 42 | * @return raw projected point. 43 | */ 44 | private function rawProject(point : Point) : Point 45 | { 46 | throw new Error("Abstract method not implemented by subclass."); 47 | return null; 48 | } 49 | 50 | /** 51 | * @return raw unprojected point. 52 | */ 53 | private function rawUnproject(point : Point) : Point 54 | { 55 | throw new Error("Abstract method not implemented by subclass."); 56 | return null; 57 | } 58 | 59 | /** 60 | * @return projected and transformed point. 61 | */ 62 | public function project(point : Point) : Point 63 | { 64 | point = rawProject(point); 65 | 66 | if (T != null) 67 | point = T.transform(point); 68 | 69 | return point; 70 | } 71 | 72 | /** 73 | * @return untransformed and unprojected point. 74 | */ 75 | public function unproject(point : Point) : Point 76 | { 77 | if (T != null) 78 | point = T.untransform(point); 79 | 80 | point = rawUnproject(point); 81 | 82 | return point; 83 | } 84 | 85 | /** 86 | * @return projected and transformed coordinate for a location. 87 | */ 88 | public function locationCoordinate(location : Location) : Coordinate 89 | { 90 | var point : Point = new Point(Math.PI * location.lon / 180, Math.PI * location.lat / 180); 91 | point = project(point); 92 | return new Coordinate(point.y, point.x, zoom); 93 | } 94 | 95 | /** 96 | * @return untransformed and unprojected location for a coordinate. 97 | */ 98 | public function coordinateLocation(coordinate : Coordinate) : Location 99 | { 100 | coordinate = coordinate.zoomTo(zoom); 101 | var point : Point = new Point(coordinate.column, coordinate.row); 102 | point = unproject(point); 103 | return new Location(180 * point.y / Math.PI, 180 * point.x / Math.PI); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /samples/old_ModestMapsExamples/src/HelloLayers.hx: -------------------------------------------------------------------------------- 1 | 2 | import com.adobe.viewsource.ViewSource; 3 | import com.modestmaps.Map; 4 | import com.modestmaps.TweenMap; 5 | import com.modestmaps.events.MapEvent; 6 | import com.modestmaps.extras.MapControls; 7 | import com.modestmaps.mapproviders.microsoft.MicrosoftAerialMapProvider; 8 | import com.modestmaps.mapproviders.yahoo.YahooAerialMapProvider; 9 | 10 | import flash.display.BlendMode; 11 | import flash.display.Sprite; 12 | import flash.display.StageAlign; 13 | import flash.display.StageScaleMode; 14 | import flash.events.Event; 15 | import flash.events.MouseEvent; 16 | 17 | @:meta(SWF(backgroundColor="#000000")) 18 | 19 | class HelloLayers extends Sprite 20 | { 21 | public var map : Map; 22 | public var overlay : Map; 23 | 24 | public function new() 25 | { 26 | super(); 27 | stage.align = StageAlign.TOP_LEFT; 28 | stage.scaleMode = StageScaleMode.NO_SCALE; 29 | 30 | ViewSource.addMenuItem(this, "srcview/index.html", true); 31 | 32 | map = new TweenMap(stage.stageWidth, stage.stageHeight, true, new MicrosoftAerialMapProvider()); 33 | map.addEventListener(MouseEvent.DOUBLE_CLICK, map.onDoubleClick); 34 | addChild(map); 35 | 36 | overlay = new TweenMap(stage.stageWidth, stage.stageHeight, false, new YahooAerialMapProvider()); 37 | overlay.mouseChildren = overlay.mouseEnabled = false; // pass thru to map 38 | addChild(overlay); 39 | 40 | // you could adjust the alpha of your overlay here: 41 | //overlay.alpha = 1; 42 | 43 | // but I want to see how Microsoft and Yahoo's aerial imagery differs, so: 44 | overlay.blendMode = BlendMode.DIFFERENCE; 45 | 46 | // these *should* be all the events you need to watch out for 47 | // fingers crossed! 48 | map.addEventListener(MapEvent.EXTENT_CHANGED, syncMaps); 49 | map.addEventListener(MapEvent.PANNED, syncMaps); 50 | map.addEventListener(MapEvent.ZOOMED_BY, syncMaps); 51 | map.addEventListener(MapEvent.STOP_ZOOMING, syncMaps); 52 | map.addEventListener(MapEvent.STOP_PANNING, syncMaps); 53 | 54 | // add these to the stage so they're on top of our overlay too 55 | addChild(new MapControls(map)); 56 | 57 | // make sure the map fills the screen: 58 | stage.addEventListener(Event.RESIZE, onStageResize); 59 | } 60 | 61 | private function syncMaps(event : MapEvent = null) : Void 62 | { 63 | // if you're using TweenMap then you need to 64 | // do this to get the animations synced: 65 | overlay.grid.setMatrix(map.grid.getMatrix()); 66 | } 67 | 68 | private function onStageResize(event : Event) : Void 69 | { 70 | map.setSize(stage.stageWidth, stage.stageHeight); 71 | overlay.setSize(stage.stageWidth, stage.stageHeight); 72 | syncMaps(); 73 | } 74 | } 75 | 76 | -------------------------------------------------------------------------------- /docs/com/modestmaps/util/package-detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.modestmaps.util Summary 8 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 |
32 |
33 |
34 |
35 | 36 |
Classes
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
 ClassDescription
 BinaryUtil 
45 |

46 |
47 |

48 | 50 |
51 |
52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /docs/com/modestmaps/flex/package-detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.modestmaps.flex Summary 8 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 |
32 |
33 |
34 |
35 | 36 |
Classes
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
 ClassDescription
 MapComponent 
45 |

46 |
47 |

48 | 50 |
51 |
52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /docs/gs/package-detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | gs Summary 8 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 |
32 |
33 |
34 |
35 | 36 |
Classes
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
 ClassDescription
 TweenFilterLite 
 TweenLite 
48 |

49 |
50 |

51 | 53 |
54 |
55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /samples/old_ModestMapsExamples/src/HelloWMS.hx: -------------------------------------------------------------------------------- 1 | 2 | import com.adobe.viewsource.ViewSource; 3 | import com.modestmaps.Map; 4 | import com.modestmaps.TweenMap; 5 | import com.modestmaps.core.MapExtent; 6 | import com.modestmaps.extras.MapControls; 7 | import com.modestmaps.mapproviders.IMapProvider; 8 | import com.modestmaps.mapproviders.WMSMapProvider; 9 | 10 | import flash.display.Sprite; 11 | import flash.display.StageAlign; 12 | import flash.display.StageScaleMode; 13 | import flash.events.Event; 14 | import flash.events.KeyboardEvent; 15 | import flash.events.MouseEvent; 16 | import flash.ui.Keyboard; 17 | 18 | @:meta(SWF(backgroundColor="#eeeeee")) 19 | 20 | class HelloWMS extends Sprite 21 | { 22 | public var map : Map; 23 | public var currentProvider : IMapProvider; 24 | public var providers : Array = []; 25 | 26 | public function new() 27 | { 28 | super(); 29 | stage.align = StageAlign.TOP_LEFT; 30 | stage.scaleMode = StageScaleMode.NO_SCALE; 31 | 32 | ViewSource.addMenuItem(this, "srcview/index.html", true); 33 | 34 | var wmsProvider : WMSMapProvider = new WMSMapProvider("http://labs.metacarta.com/wms/vmap0", { 35 | LAYERS : "basic", 36 | SERVICE : "WMS", 37 | VERSION : "1.1.1", 38 | REQUEST : "GetMap", 39 | STYLES : "", 40 | SRS : WMSMapProvider.EPSG_900913, 41 | EXCEPTIONS : "application/vnd.ogc.se_inimage", 42 | FORMAT : "image/jpeg", 43 | WIDTH : "256", 44 | HEIGHT : "256", 45 | 46 | }); 47 | providers.push(wmsProvider); 48 | 49 | /* wmsProvider = new WMSMapProvider("http://labs.metacarta.com/wms/vmap0", 50 | { 51 | LAYERS: 'basic', 52 | SERVICE: 'WMS', 53 | VERSION: '1.1.1', 54 | REQUEST: 'GetMap', 55 | STYLES: '', 56 | SRS: WMSMapProvider.EPSG_900913, 57 | EXCEPTIONS: 'application/vnd.ogc.se_inimage', 58 | FORMAT: 'image/jpeg', 59 | WIDTH: '256', 60 | HEIGHT: '256' 61 | }); 62 | providers.push(wmsProvider); */ 63 | 64 | map = new TweenMap(stage.stageWidth, stage.stageHeight, true, providers[0], new MapExtent(48.383, 43.300, 5.367, -4.500)); 65 | map.addEventListener(MouseEvent.DOUBLE_CLICK, map.onDoubleClick); 66 | addChild(map); 67 | 68 | map.addChild(new MapControls(map)); 69 | 70 | stage.addEventListener(Event.RESIZE, onStageResize); 71 | stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp); 72 | } 73 | 74 | private function onKeyUp(event : KeyboardEvent) : Void 75 | { 76 | if (event.keyCode == Keyboard.SPACE) { 77 | var provider : IMapProvider = map.getMapProvider(); 78 | var index : Int = Lambda.indexOf(providers, provider); 79 | index = (index + 1) % providers.length; 80 | map.setMapProvider(providers[index]); 81 | } 82 | } 83 | 84 | private function onStageResize(event : Event) : Void 85 | { 86 | map.setSize(stage.stageWidth, stage.stageHeight); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /com/modestmaps/extras/Overlay.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.extras; 2 | 3 | import com.modestmaps.Map; 4 | import com.modestmaps.events.MapEvent; 5 | import openfl.display.Sprite; 6 | import openfl.events.Event; 7 | import openfl.geom.Point; 8 | 9 | 10 | /** Overlay simplifies adding vector graphics to your map. 11 | * Subclass Overlay and override the redraw(sprite:Sprite) method to use it. 12 | */ 13 | class Overlay extends Sprite 14 | { 15 | public var map : Map; 16 | 17 | private var panStart : Point; 18 | 19 | private var polySprite : Sprite = new Sprite(); 20 | private var polyCont : Sprite = new Sprite(); 21 | 22 | public function new(map : Map) 23 | { 24 | super(); 25 | this.mouseEnabled = false; 26 | this.mouseChildren = false; 27 | this.map = map; 28 | this.cacheAsBitmap = true; 29 | // this.blendMode = BlendMode.MULTIPLY; 30 | 31 | addChild(polyCont); 32 | polyCont.addChild(polySprite); 33 | addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); 34 | } 35 | 36 | private function onAddedToStage(event : Event) : Void 37 | { 38 | refresh(); 39 | onMapResize(null); 40 | map.addEventListener(MapEvent.START_PANNING, onMapStartPan); 41 | map.addEventListener(MapEvent.PANNED, onMapPanned); 42 | map.addEventListener(MapEvent.STOP_PANNING, onMapStopPan); 43 | map.addEventListener(MapEvent.ZOOMED_BY, onMapZoomedBy); 44 | map.addEventListener(MapEvent.STOP_ZOOMING, onEndZoom); 45 | map.addEventListener(MapEvent.EXTENT_CHANGED, onMapChange); 46 | map.addEventListener(MapEvent.RESIZED, onMapResize); 47 | } 48 | 49 | private function onMapResize(event : Event) : Void 50 | { 51 | /* graphics.clear(); 52 | graphics.beginFill(0xcccccc); 53 | var w:Number = map.getWidth(); 54 | var h:Number = map.getHeight(); 55 | graphics.drawRect(0, 0, w, h); */ 56 | refresh(); 57 | } 58 | 59 | public function refresh() : Void 60 | { 61 | polyCont.scaleX = polyCont.scaleY = 1.0; 62 | polyCont.x = stage.stageWidth / 2; 63 | polyCont.y = stage.stageHeight / 2; 64 | polySprite.x = stage.stageWidth / 2; 65 | polySprite.y = stage.stageHeight / 2; 66 | redraw(polySprite); 67 | } 68 | 69 | /** redraw the overlay onto the given Sprite - override this in your subclass */ 70 | public function redraw(sprite : Sprite) : Void 71 | { 72 | trace("*** you should subclass Overlay and override redraw rather than using Overlay directly"); 73 | } 74 | 75 | private function onMapZoomedBy(event : MapEvent) : Void 76 | { 77 | polyCont.scaleX = polyCont.scaleY = Math.pow(2, event.zoomDelta); 78 | } 79 | 80 | private function onEndZoom(event : MapEvent) : Void 81 | { 82 | refresh(); 83 | } 84 | 85 | private function onMapChange(event : MapEvent) : Void 86 | { 87 | refresh(); 88 | } 89 | 90 | private function onMapStartPan(event : MapEvent) : Void 91 | { 92 | panStart = new Point(polyCont.x, polyCont.y); 93 | } 94 | 95 | private function onMapStopPan(event : MapEvent) : Void 96 | { 97 | refresh(); 98 | } 99 | 100 | private function onMapPanned(event : MapEvent) : Void 101 | { 102 | polyCont.x = panStart.x + event.panDelta.x; 103 | polyCont.y = panStart.y + event.panDelta.y; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /docs/com/modestmaps/package-detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.modestmaps Summary 8 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 |
32 |
33 |
34 |
35 | 36 |
Classes
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
 ClassDescription
 Map 
 TweenMap 
48 |

49 |
50 |

51 | 53 |
54 |
55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/DynamicZoomifyMapProvider.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.mapproviders; 2 | 3 | import com.modestmaps.geo.LinearProjection; 4 | import com.modestmaps.geo.Location; 5 | import com.modestmaps.geo.MercatorProjection; 6 | import com.modestmaps.geo.Transformation; 7 | import com.modestmaps.mapproviders.IMapProvider; 8 | import openfl.geom.Point; 9 | 10 | 11 | 12 | class DynamicZoomifyMapProvider extends AbstractZoomifyMapProvider implements IMapProvider 13 | { 14 | public function new(baseURL : String, imageWidth : Float, imageHeight : Float, mercator : Bool, 15 | l1 : Location, p1 : Point, l2 : Location, p2 : Point, l3 : Location, p3 : Point) 16 | { 17 | super(); 18 | defineImageProperties(baseURL, imageWidth, imageHeight); 19 | var projectionZoom : Int = Math.ceil(Math.log(Math.max(imageWidth, imageHeight)) / Math.LN2); 20 | var t : Transformation = deriveTransformation(mercator, l1, p1, l2, p2, l3, p3); 21 | __projection = (mercator) ? new MercatorProjection(projectionZoom, t) : new LinearProjection(projectionZoom, t); 22 | } 23 | 24 | private function rawProject(lat : Float) : Float 25 | { 26 | return Math.log(Math.tan(0.25 * Math.PI + 0.5 * lat)); 27 | } 28 | 29 | /** Generates a transform based on three pairs of points, l1 -> p1, l2 -> p2, l3 -> p3. */ 30 | private function deriveTransformation(mercator : Bool, l1 : Location, p1 : Point, l2 : Location, p2 : Point, l3 : Location, p3 : Point) : Transformation 31 | { 32 | var deg2rad : Float = Math.PI / 180.0; 33 | 34 | var a1x : Float = l1.lon * deg2rad; 35 | var a1y : Float = (mercator) ? rawProject(l1.lat * deg2rad) : l1.lat * deg2rad; 36 | var a2x : Float = p1.x; 37 | var a2y : Float = p1.y; 38 | var b1x : Float = l2.lon * deg2rad; 39 | var b1y : Float = (mercator) ? rawProject(l2.lat * deg2rad) : l2.lat * deg2rad; 40 | var b2x : Float = p2.x; 41 | var b2y : Float = p2.y; 42 | var c1x : Float = l3.lon * deg2rad; 43 | var c1y : Float = (mercator) ? rawProject(l3.lat * deg2rad) : l3.lat * deg2rad; 44 | var c2x : Float = p3.x; 45 | var c2y : Float = p3.y; 46 | 47 | var x : Array = linearSolution(a1x, a1y, a2x, b1x, b1y, b2x, c1x, c1y, c2x); 48 | var y : Array = linearSolution(a1x, a1y, a2y, b1x, b1y, b2y, c1x, c1y, c2y); 49 | 50 | return new Transformation(x[0], x[1], x[2], y[0], y[1], y[2]); 51 | } 52 | 53 | /** Solves a system of linear equations. 54 | 55 | t1 = (a * r1) + (b + s1) + c 56 | t2 = (a * r2) + (b + s2) + c 57 | t3 = (a * r3) + (b + s3) + c 58 | 59 | r1 - t3 are the known values. 60 | a, b, c are the unknowns to be solved. 61 | returns the a, b, c coefficients. 62 | */ 63 | private function linearSolution(r1 : Float, s1 : Float, t1 : Float, r2 : Float, s2 : Float, t2 : Float, r3 : Float, s3 : Float, t3 : Float) : Array 64 | { 65 | var a : Float = (((t2 - t3) * (s1 - s2)) - ((t1 - t2) * (s2 - s3))) / (((r2 - r3) * (s1 - s2)) - ((r1 - r2) * (s2 - s3))); 66 | var b : Float = (((t2 - t3) * (r1 - r2)) - ((t1 - t2) * (r2 - r3))) / (((s2 - s3) * (r1 - r2)) - ((s1 - s2) * (r2 - r3))); 67 | var c : Float = t1 - (r1 * a) - (s1 * b); 68 | return [a, b, c]; 69 | } 70 | 71 | override public function toString() : String 72 | { 73 | return "DYNAMIC_ZOOMIFY"; 74 | } 75 | } 76 | 77 | -------------------------------------------------------------------------------- /com/modestmaps/core/Tile.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * vim:et sts=4 sw=4 cindent: 3 | * $Id$ 4 | */ 5 | 6 | package com.modestmaps.core; 7 | 8 | //import nme.errors.Error; 9 | 10 | import openfl.display.DisplayObject; 11 | import openfl.display.Loader; 12 | import openfl.display.Sprite; 13 | 14 | class Tile extends Sprite 15 | { 16 | public static var count : Int = 0; 17 | 18 | // not a coordinate, because it's very important these are ints 19 | public var zoom : Int; 20 | public var row : Int; 21 | public var column : Int; 22 | 23 | public function new(column : Int, row : Int, zoom : Int) 24 | { 25 | super(); 26 | init(column, row, zoom); 27 | 28 | // otherwise you'll get seams between tiles :( 29 | this.cacheAsBitmap = false; 30 | 31 | count++; 32 | } 33 | 34 | /** override this in a subclass and call grid.setTileClass if you want to draw on your tiles */ 35 | public function init(column : Int, row : Int, zoom : Int) : Void 36 | { 37 | this.zoom = zoom; 38 | this.row = row; 39 | this.column = column; 40 | hide(); 41 | } 42 | 43 | /** once TileGrid is done with a tile, it will call destroy and possibly reuse it later */ 44 | public function destroy() : Void 45 | { 46 | while (numChildren > 0) 47 | { 48 | var child : DisplayObject = removeChildAt(0); 49 | if (Std.is(child, Loader)) 50 | { 51 | cast((child), Loader).unload(); 52 | } 53 | } 54 | graphics.clear(); 55 | } 56 | 57 | public function isShowing() : Bool 58 | { 59 | return this.alpha == 1.0; 60 | } 61 | 62 | public function showNow() : Void 63 | { 64 | this.alpha = 1.0; 65 | } 66 | 67 | public function show() : Void 68 | { 69 | this.alpha = 1.0; 70 | } 71 | 72 | public function hide() : Void 73 | { 74 | this.alpha = 0.0; 75 | } 76 | 77 | public function paintError(w : Float = 256, h : Float = 256) : Void 78 | { 79 | // length of 'X' side, padding from edge, weight of 'X' symbol 80 | var size : Int = 32; 81 | var padding : Int = 4; 82 | var weight : Int = 4; 83 | 84 | this.graphics.clear(); 85 | 86 | this.graphics.beginFill(0x808080); 87 | this.graphics.drawRect(0, 0, w, h); 88 | 89 | this.graphics.moveTo(0, 0); 90 | this.graphics.beginFill(0x444444, 1); 91 | this.graphics.lineTo(size, 0); 92 | this.graphics.lineTo(size, size); 93 | this.graphics.lineTo(0, size); 94 | this.graphics.lineTo(0, 0); 95 | this.graphics.endFill(); 96 | 97 | this.graphics.moveTo(weight + padding, padding); 98 | this.graphics.beginFill(0x888888, 1); 99 | this.graphics.lineTo(padding, weight + padding); 100 | this.graphics.lineTo(size - weight - padding, size - padding); 101 | this.graphics.lineTo(size - padding, size - weight - padding); 102 | this.graphics.lineTo(weight + padding, padding); 103 | this.graphics.endFill(); 104 | 105 | this.graphics.moveTo(size - weight - padding, padding); 106 | this.graphics.beginFill(0x888888, 1); 107 | this.graphics.lineTo(size - padding, weight + padding); 108 | this.graphics.lineTo(weight + padding, size - padding); 109 | this.graphics.lineTo(padding, size - weight - padding); 110 | this.graphics.lineTo(size - weight - padding, padding); 111 | this.graphics.endFill(); 112 | 113 | } 114 | } 115 | 116 | -------------------------------------------------------------------------------- /samples/old_ModestMapsExamples/src/HelloMarkers.hx: -------------------------------------------------------------------------------- 1 | 2 | import com.adobe.viewsource.ViewSource; 3 | import com.modestmaps.Map; 4 | import com.modestmaps.TweenMap; 5 | import com.modestmaps.extras.MapControls; 6 | import com.modestmaps.extras.MapCopyright; 7 | import com.modestmaps.extras.ZoomSlider; 8 | import com.modestmaps.geo.Location; 9 | import com.modestmaps.mapproviders.microsoft.MicrosoftHybridMapProvider; 10 | 11 | import flash.display.Sprite; 12 | import flash.display.StageAlign; 13 | import flash.display.StageScaleMode; 14 | import flash.events.Event; 15 | import flash.events.MouseEvent; 16 | 17 | @:meta(SWF(backgroundColor="#ffffff")) 18 | 19 | 20 | 21 | 22 | 23 | class HelloMarkers extends Sprite 24 | { 25 | public var map : Map; 26 | 27 | public function new() 28 | { 29 | super(); 30 | stage.align = StageAlign.TOP_LEFT; 31 | stage.scaleMode = StageScaleMode.NO_SCALE; 32 | 33 | ViewSource.addMenuItem(this, "srcview/index.html", true); 34 | 35 | // make a draggable TweenMap so that we have smooth zooming and panning animation 36 | // use Microsoft's Hybrid tiles. 37 | map = new TweenMap(stage.stageWidth, stage.stageHeight, true, new MicrosoftHybridMapProvider()); 38 | map.addEventListener(MouseEvent.DOUBLE_CLICK, map.onDoubleClick); 39 | 40 | // add some basic controls 41 | // you're free to use these, but I'd make my own if I was a Flash coder :) 42 | map.addChild(new MapControls(map)); 43 | map.addChild(new ZoomSlider(map)); 44 | 45 | // add a copyright handler 46 | // (this is a bit of a hack, but works well enough for now) 47 | map.addChild(new MapCopyright(map)); 48 | 49 | // create an instance of the Marker class defined below 50 | // (location from getlatlon.com, thanks Simon!) 51 | var marker : Marker = new Marker(new Location(37.645614, -120.993705), "Modesto, CA"); 52 | 53 | // add the marker to the map's default MarkerClip 54 | // (later on you can make your own MarkerClips and layer them if you want) 55 | map.putMarker(marker.location, marker); 56 | 57 | // show the marker 58 | // 11 seems like a good zoom level... 59 | map.setCenterZoom(marker.location, 11); 60 | 61 | // add map to stage last, so as to avoid markers jumping around 62 | addChild(map); 63 | 64 | // make sure the map always fills the screen: 65 | stage.addEventListener(Event.RESIZE, onStageResize); 66 | } 67 | 68 | public function onStageResize(event : Event) : Void 69 | { 70 | map.setSize(stage.stageWidth, stage.stageHeight); 71 | } 72 | } 73 | 74 | 75 | 76 | class Marker extends Sprite 77 | { 78 | public var text : String; 79 | public var location : Location; 80 | 81 | public function new(location : Location, text : String) 82 | { 83 | super(); 84 | this.location = location; 85 | this.text = text; 86 | 87 | graphics.beginFill(0x000000); 88 | graphics.drawCircle(0, 0, 12); 89 | graphics.beginFill(0xff9900); 90 | graphics.drawCircle(0, 0, 10); 91 | graphics.beginFill(0xffff00); 92 | graphics.drawCircle(0, 0, 5); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /docs/com/modestmaps/events/package-detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.modestmaps.events Summary 8 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 |
32 |
33 |
34 |
35 | 36 |
Classes
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
 ClassDescription
 MapEvent 
 MarkerEvent 
48 |

49 |
50 |

51 | 53 |
54 |
55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /com/modestmaps/events/MapEvent.hx: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id$ 3 | */ 4 | 5 | package com.modestmaps.events; 6 | 7 | import com.modestmaps.core.MapExtent; 8 | import com.modestmaps.mapproviders.IMapProvider; 9 | import openfl.events.Event; 10 | import openfl.geom.Point; 11 | 12 | 13 | class MapEvent extends Event 14 | { 15 | public static inline var INITIALIZED : String = "mapInitialized"; 16 | public static inline var CHANGED : String = "mapChanged"; 17 | 18 | public static inline var START_ZOOMING : String = "startZooming"; 19 | public static inline var STOP_ZOOMING : String = "stopZooming"; 20 | public var zoomLevel : Float; 21 | 22 | public static inline var ZOOMED_BY : String = "zoomedBy"; 23 | public var zoomDelta : Float; 24 | 25 | public static inline var START_PANNING : String = "startPanning"; 26 | public static inline var STOP_PANNING : String = "stopPanning"; 27 | 28 | public static inline var PANNED : String = "panned"; 29 | public var panDelta : Point; 30 | 31 | public static inline var RESIZED : String = "resized"; 32 | public var newSize : Point; 33 | 34 | public static inline var COPYRIGHT_CHANGED : String = "copyrightChanged"; 35 | public var newCopyright : String; 36 | 37 | public static inline var BEGIN_EXTENT_CHANGE : String = "beginExtentChange"; 38 | public var oldExtent : MapExtent; 39 | 40 | public static inline var EXTENT_CHANGED : String = "extentChanged"; 41 | public var newExtent : MapExtent; 42 | 43 | public static inline var MAP_PROVIDER_CHANGED : String = "mapProviderChanged"; 44 | public var newMapProvider : IMapProvider; 45 | 46 | public static inline var BEGIN_TILE_LOADING : String = "beginTileLoading"; 47 | public static inline var ALL_TILES_LOADED : String = "alLTilesLoaded"; 48 | 49 | /** listen out for this if you want to be sure map is in its final state before reprojecting markers etc. */ 50 | public static inline var RENDERED : String = "rendered"; 51 | 52 | public function new(type : String, rest : Array) 53 | { 54 | super(type, true, true); 55 | 56 | switch (type) 57 | { 58 | case PANNED: 59 | if (rest.length > 0 && Std.is(rest[0], Point)) 60 | { 61 | panDelta = rest[0]; 62 | } 63 | case ZOOMED_BY: 64 | if (rest.length > 0 && Std.is(rest[0], Float)) 65 | { 66 | zoomDelta = rest[0]; 67 | } 68 | case EXTENT_CHANGED: 69 | if (rest.length > 0 && Std.is(rest[0], MapExtent)) 70 | { 71 | newExtent = rest[0]; 72 | } 73 | case START_ZOOMING, STOP_ZOOMING: 74 | if (rest.length > 0 && Std.is(rest[0], Float)) 75 | { 76 | zoomLevel = rest[0]; 77 | } 78 | case RESIZED: 79 | if (rest.length > 0 && Std.is(rest[0], Point)) 80 | { 81 | newSize = rest[0]; 82 | } 83 | case COPYRIGHT_CHANGED: 84 | if (rest.length > 0 && Std.is(rest[0], String)) 85 | { 86 | newCopyright = rest[0]; 87 | } 88 | case BEGIN_EXTENT_CHANGE: 89 | if (rest.length > 0 && Std.is(rest[0], MapExtent)) 90 | { 91 | oldExtent = rest[0]; 92 | } 93 | case MAP_PROVIDER_CHANGED: 94 | if (rest.length > 0 && Std.is(rest[0], IMapProvider)) 95 | { 96 | newMapProvider = rest[0]; 97 | } 98 | } 99 | } 100 | 101 | override public function clone() : Event 102 | { 103 | return new MapEvent(this.type,null); 104 | } 105 | } 106 | 107 | -------------------------------------------------------------------------------- /docs/com/modestmaps/extras/ui/package-detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.modestmaps.extras.ui Summary 8 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 |
32 |
33 |
34 |
35 | 36 |
Classes
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 |
 ClassDescription
 Button 
 FullScreenButton 
48 |

49 |
50 |

51 | 53 |
54 |
55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /docs/package-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Package List - API Documentation 6 | 7 | 8 | 9 | 10 | 11 | 12 |

13 | Packages 14 |

15 | 16 | 17 | 20 | 21 | 22 | 25 | 26 | 27 | 30 | 31 | 32 | 35 | 36 | 37 | 40 | 41 | 42 | 45 | 46 | 47 | 50 | 51 | 52 | 55 | 56 | 57 | 60 | 61 | 62 | 65 | 66 | 67 | 70 | 71 | 72 | 75 | 76 | 77 | 78 | 79 |
com.modestmaps 18 |
19 |
com.modestmaps.core 23 |
24 |
com.modestmaps.events 28 |
29 |
com.modestmaps.extras 33 |
34 |
com.modestmaps.extras.ui 38 |
39 |
com.modestmaps.flex 43 |
44 |
com.modestmaps.geo 48 |
49 |
com.modestmaps.mapproviders 53 |
54 |
com.modestmaps.mapproviders.microsoft 58 |
59 |
com.modestmaps.mapproviders.yahoo 63 |
64 |
com.modestmaps.overlays 68 |
69 |
com.modestmaps.util 73 |
74 |
gs
80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/microsoft/MicrosoftProvider.hx: -------------------------------------------------------------------------------- 1 | 2 | package com.modestmaps.mapproviders.microsoft; 3 | 4 | import com.modestmaps.core.Coordinate; 5 | import com.modestmaps.mapproviders.AbstractMapProvider; 6 | import com.modestmaps.mapproviders.IMapProvider; 7 | import com.modestmaps.util.BinaryUtil; 8 | import haxe.ds.StringMap; 9 | 10 | /** 11 | * @author tom 12 | * @author darren 13 | * @author migurski 14 | * $Id:$ 15 | */ 16 | 17 | class MicrosoftProvider extends AbstractMapProvider implements IMapProvider 18 | { 19 | public static inline var AERIAL : String = "AERIAL"; 20 | public static inline var ROAD : String = "ROAD"; 21 | public static inline var HYBRID : String = "HYBRID"; 22 | 23 | public static var serverSalt : Int = Std.int(Math.random() * 4); 24 | 25 | private static var urlStart:StringMap = [ 26 | AERIAL => "http://a", 27 | ROAD => "http://r", 28 | HYBRID => "http://h" 29 | ]; 30 | 31 | private static var urlMiddle:StringMap = [ 32 | AERIAL => ".ortho.tiles.virtualearth.net/tiles/a", 33 | ROAD => ".ortho.tiles.virtualearth.net/tiles/r", 34 | HYBRID => ".ortho.tiles.virtualearth.net/tiles/h" 35 | ]; 36 | 37 | private static var urlEnd:StringMap = [ 38 | AERIAL => ".jpeg?g=90", 39 | ROAD => ".png?g=90", 40 | HYBRID => ".jpeg?g=90" 41 | ]; 42 | 43 | private var type : String; 44 | private var hillShading : Bool; 45 | 46 | public function new(type : String = ROAD, hillShading : Bool = true, minZoom : Int = AbstractMapProvider.MIN_ZOOM, maxZoom : Int = AbstractMapProvider.MAX_ZOOM) 47 | { 48 | super(minZoom, maxZoom); 49 | 50 | this.type = type; 51 | this.hillShading = hillShading; 52 | 53 | if (hillShading) 54 | { 55 | urlEnd.set(ROAD, urlEnd.get(ROAD) + "&shading=hill"); 56 | } 57 | // Microsoft don't have a zoom level 0 right now: 58 | 59 | __topLeftOutLimit.zoomTo(1); 60 | } 61 | 62 | private function getZoomString(coord : Coordinate) : String 63 | { 64 | var sourceCoord : Coordinate = sourceCoordinate(coord); 65 | 66 | // convert row + col to zoom string 67 | // padded with zeroes so we end up with zoom digits after slicing: 68 | var rowBinaryString : String = BinaryUtil.convertToBinary(Std.int(sourceCoord.row)); 69 | rowBinaryString = rowBinaryString.substring(Std.int(-sourceCoord.zoom)); 70 | 71 | var colBinaryString : String = BinaryUtil.convertToBinary(Std.int(sourceCoord.column)); 72 | colBinaryString = colBinaryString.substring(Std.int(-sourceCoord.zoom)); 73 | 74 | // generate zoom string by combining strings 75 | var zoomString : String = ""; 76 | 77 | var i : Int = 0; 78 | while (i < sourceCoord.zoom) 79 | { 80 | zoomString += BinaryUtil.convertToDecimal(rowBinaryString.charAt(i) + colBinaryString.charAt(i)); 81 | i += 1; 82 | } 83 | 84 | return zoomString; 85 | } 86 | 87 | public function toString() : String 88 | { 89 | return "MICROSOFT_" + type; 90 | } 91 | 92 | public function getTileUrls(coord : Coordinate) : Array 93 | { 94 | if (coord.row < 0 || coord.row >= Math.pow(2, coord.zoom)) 95 | { 96 | return null; 97 | } // this is so that requests will be consistent in this session, rather than totally random 98 | 99 | var server : Int = Std.int(Math.abs(serverSalt + coord.row + coord.column + coord.zoom) % 4); 100 | return [urlStart.get(type) + server + urlMiddle.get(type) + getZoomString(coord) + urlEnd.get(type)]; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /com/modestmaps/extras/ui/Button.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.extras.ui; 2 | 3 | import openfl.display.Sprite; 4 | import openfl.events.MouseEvent; 5 | import openfl.geom.ColorTransform; 6 | 7 | class Button extends Sprite 8 | { 9 | public static inline var LEFT : String = "left"; 10 | public static inline var RIGHT : String = "right"; 11 | public static inline var UP : String = "up"; 12 | public static inline var DOWN : String = "down"; 13 | public static inline var IN : String = "in"; 14 | public static inline var OUT : String = "out"; 15 | 16 | public var overTransform : ColorTransform; 17 | public var outTransform : ColorTransform; 18 | 19 | public function new(type : String = null, radius : Float = 9, bgColor : Int = 0xFFFFFF, fgColor : Int = 0x000000, beveled : Bool = true) 20 | { 21 | super(); 22 | if (overTransform == null) overTransform = new ColorTransform(1, 1, 1); 23 | if (outTransform == null) outTransform = new ColorTransform(1, .9, .6); 24 | 25 | useHandCursor = true; 26 | buttonMode = true; 27 | cacheAsBitmap = true; 28 | 29 | addEventListener(MouseEvent.MOUSE_OVER, onMouseOver); 30 | addEventListener(MouseEvent.MOUSE_OUT, onMouseOut); 31 | 32 | graphics.clear(); 33 | if (beveled) 34 | { 35 | graphics.beginFill(0xdddddd); 36 | graphics.drawRoundRect(0, 0, 20, 20, radius, radius); 37 | graphics.beginFill(bgColor); 38 | graphics.drawRoundRect(0, 0, 18, 18, radius, radius); 39 | graphics.beginFill(0xbbbbbb); 40 | graphics.drawRoundRect(2, 2, 18, 18, radius, radius); 41 | graphics.beginFill(0xdddddd); 42 | graphics.drawRoundRect(1, 1, 18, 18, radius, radius); 43 | } 44 | else 45 | { 46 | graphics.beginFill(bgColor); 47 | graphics.drawRoundRect(0, 0, 20, 20, radius, radius); 48 | } 49 | 50 | switch (type) 51 | { 52 | 53 | // draw arrows... 54 | case LEFT: 55 | graphics.beginFill(fgColor); 56 | graphics.moveTo(14, 6); 57 | graphics.lineTo(6, 10); 58 | graphics.lineTo(14, 14); 59 | graphics.lineTo(14, 6); 60 | 61 | case RIGHT: 62 | graphics.beginFill(fgColor); 63 | graphics.moveTo(6, 6); 64 | graphics.lineTo(14, 10); 65 | graphics.lineTo(6, 14); 66 | graphics.lineTo(6, 6); 67 | 68 | case UP: 69 | graphics.beginFill(fgColor); 70 | graphics.moveTo(6, 14); 71 | graphics.lineTo(10, 6); 72 | graphics.lineTo(14, 14); 73 | graphics.lineTo(6, 14); 74 | 75 | case DOWN: 76 | graphics.beginFill(fgColor); 77 | graphics.moveTo(6, 6); 78 | graphics.lineTo(10, 14); 79 | graphics.lineTo(14, 6); 80 | graphics.lineTo(6, 6); 81 | 82 | case IN: 83 | // draw plus... 84 | graphics.lineStyle(2, fgColor, 1.0, true); 85 | graphics.moveTo(7, 10); 86 | graphics.lineTo(13, 10); 87 | graphics.lineTo(7, 10); 88 | graphics.moveTo(10, 7); 89 | graphics.lineTo(10, 13); 90 | graphics.lineTo(10, 7); 91 | 92 | case OUT: 93 | // draw minus... 94 | graphics.lineStyle(2, fgColor, 1.0, true); 95 | graphics.moveTo(7, 10); 96 | graphics.lineTo(13, 10); 97 | graphics.lineTo(7, 10); 98 | } 99 | 100 | transform.colorTransform = outTransform; 101 | } 102 | 103 | public function onMouseOver(event : MouseEvent = null) : Void 104 | { 105 | transform.colorTransform = overTransform; 106 | } 107 | 108 | public function onMouseOut(event : MouseEvent = null) : Void 109 | { 110 | transform.colorTransform = outTransform; 111 | } 112 | } 113 | 114 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/DailyPlanetProvider.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.mapproviders; 2 | 3 | import com.modestmaps.core.Coordinate; 4 | import com.modestmaps.geo.LinearProjection; 5 | import com.modestmaps.geo.Transformation; 6 | import com.modestmaps.mapproviders.IMapProvider; 7 | 8 | 9 | class DailyPlanetProvider extends AbstractMapProvider implements IMapProvider 10 | { 11 | private static inline var MIN_ZOOM : Int = 1; 12 | private static inline var MAX_ZOOM : Int = 6; 13 | 14 | /** WARNING: this is extremely experimental, and 15 | * it might not make the correct calls to NASA every time 16 | * we are still testing 512px providers, too */ 17 | public function new(minZoom : Int = MIN_ZOOM, maxZoom : Int = MAX_ZOOM) 18 | { 19 | super(); 20 | 21 | var t : Transformation = new Transformation(0.3183098861837907, 0, 1, 22 | 0, -0.3183098861837907, 0.5); 23 | 24 | __projection = new LinearProjection(1, t); 25 | 26 | __topLeftOutLimit = new Coordinate(0, Float.NEGATIVE_INFINITY, 0).zoomTo(minZoom); 27 | __bottomRightInLimit = (new Coordinate(1, Float.POSITIVE_INFINITY, 0)).zoomTo(maxZoom); 28 | } 29 | 30 | public function getTileUrls(coord : Coordinate) : Array 31 | { 32 | // zoom level 0 is a 512x512 tile containing a linearly projected map of the world in the top half: 33 | // http://wms.jpl.nasa.gov/wms.cgi?request=GetMap&width=512&height=512&layers=daily_planet&styles=&srs=EPSG:4326&format=image/jpeg&bbox=-180,-270,180,90 34 | // the -270 there works, and kind of makes sense, and gives the same image as: 35 | // http://wms.jpl.nasa.gov/wms.cgi?request=GetMap&width=512&height=512&layers=daily_planet&styles=&srs=EPSG:4326&format=image/jpeg&bbox=-180,-90,180,90 36 | 37 | coord = sourceCoordinate(coord); 38 | 39 | var tilesWide : Float = Math.pow(2, coord.zoom); 40 | var tilesHigh : Float = Math.pow(2, coord.zoom - 1); 41 | 42 | var w : Float = -180.0 + (360.0 * coord.column / tilesWide); 43 | var n : Float = 90 - (180.0 * coord.row / tilesHigh); 44 | var e : Float = w + (360.0 / tilesWide); 45 | var s : Float = n + (180.0 / tilesHigh); 46 | 47 | var bbox : String = [w, s, e, n].join(","); 48 | 49 | // don't use URLVariables to build this URL, because there's a chance that the cache might require things in a particular order 50 | // here's the pattern: request=GetMap&layers=daily_planet&srs=EPSG:4326&format=image/jpeg&styles=&width=512&height=512&bbox=-180,88,-178,90 51 | // from http://onearth.jpl.nasa.gov/wms.cgi?request=GetTileService 52 | var url : String = "http://wms.jpl.nasa.gov/wms.cgi?" + 53 | "request=GetMap" + 54 | "&layers=daily_planet" + 55 | "&srs=EPSG:4326" + 56 | "&format=image/jpeg" + 57 | "&styles=" + 58 | "&width=512" + 59 | "&height=512" + 60 | "&bbox=" + bbox; 61 | 62 | //trace(coord, bbox); 63 | //trace(url); 64 | return [url]; 65 | } 66 | 67 | public function toString() : String 68 | { 69 | return "DAILY_PLANET"; 70 | } 71 | 72 | override public function sourceCoordinate(coord : Coordinate) : Coordinate 73 | { 74 | var tilesWide : Float = Math.pow(2, coord.zoom); 75 | var tilesHigh : Float = Math.ceil(Math.pow(2, coord.zoom - 1)); 76 | coord = coord.copy(); 77 | while (coord.row < 0)coord.row += tilesHigh; 78 | while (coord.column < 0)coord.column += tilesWide; 79 | coord.row %= tilesHigh; 80 | coord.column %= tilesWide; 81 | return coord; 82 | } 83 | 84 | override private function get_TileWidth() : Float 85 | { 86 | return 512; 87 | } 88 | 89 | override private function get_TileHeight() : Float 90 | { 91 | return 512; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /com/modestmaps/extras/ZoomBox.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.extras; 2 | 3 | import com.modestmaps.Map; 4 | import com.modestmaps.core.MapExtent; 5 | import com.modestmaps.geo.Location; 6 | import openfl.display.LineScaleMode; 7 | import openfl.display.Shape; 8 | import openfl.display.Sprite; 9 | import openfl.events.Event; 10 | import openfl.events.MouseEvent; 11 | import openfl.geom.Point; 12 | import openfl.geom.Rectangle; 13 | 14 | 15 | class ZoomBox extends Sprite 16 | { 17 | private var map : Map; 18 | private var box : Shape; 19 | 20 | private var p : Point; 21 | 22 | public function new(map : Map, 23 | boxLineThickness : Float = 0, 24 | boxLineColor : UInt = 0xff0000, 25 | boxFillColor : UInt = 0xffffff, 26 | boxFillAlpha : Float = 0.2) 27 | { 28 | super(); 29 | this.map = map; 30 | 31 | box = new Shape(); 32 | box.graphics.lineStyle(boxLineThickness, boxLineColor, 1, false, LineScaleMode.NONE); 33 | box.graphics.beginFill(boxFillColor, boxFillAlpha); 34 | box.graphics.drawRect(0, 0, 100, 100); 35 | box.graphics.endFill(); 36 | box.visible = false; 37 | addChild(box); 38 | 39 | addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); 40 | } 41 | 42 | private function onAddedToStage(event : Event) : Void 43 | { 44 | removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); 45 | stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, true, -100); 46 | addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage); 47 | } 48 | 49 | private function onRemovedFromStage(event : Event) : Void 50 | { 51 | removeEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage); 52 | stage.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, true); 53 | addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); 54 | } 55 | 56 | private function onMouseDown(event : MouseEvent) : Void 57 | { 58 | if (event.shiftKey) 59 | { 60 | map.grid.mouseEnabled = false; 61 | p = new Point(stage.mouseX, stage.mouseY); 62 | p = map.globalToLocal(p); 63 | box.x = p.x; 64 | box.y = p.y; 65 | box.scaleX = box.scaleY = 0; 66 | stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp); 67 | stage.addEventListener(Event.MOUSE_LEAVE, onMouseUp); 68 | stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); 69 | event.stopImmediatePropagation(); 70 | } 71 | } 72 | 73 | private function onMouseUp(event : Event) : Void 74 | { 75 | box.visible = false; 76 | 77 | if (Math.abs(box.scaleX) > 0 && Math.abs(box.scaleY) > 0) 78 | { 79 | var rect : Rectangle = box.getBounds(map); 80 | 81 | var nw : Location = map.pointLocation(rect.topLeft); 82 | var se : Location = map.pointLocation(rect.bottomRight); 83 | 84 | // TODO: what happens at the international date line? 85 | var extent : MapExtent = new MapExtent(nw.lat, se.lat, se.lon, nw.lon); 86 | map.setExtent(extent); 87 | } 88 | 89 | stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp); 90 | stage.removeEventListener(Event.MOUSE_LEAVE, onMouseUp); 91 | stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); 92 | 93 | event.stopImmediatePropagation(); 94 | 95 | map.grid.mouseEnabled = true; 96 | } 97 | 98 | private function onMouseMove(event : MouseEvent) : Void 99 | { 100 | var mouseP : Point = map.globalToLocal(new Point(stage.mouseX, stage.mouseY)); 101 | var movement : Point = p.subtract(mouseP); 102 | box.visible = true; 103 | box.scaleX = -movement.x / 100; 104 | box.scaleY = -movement.y / 100; 105 | } 106 | } 107 | 108 | -------------------------------------------------------------------------------- /com/modestmaps/extras/MapScale.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.extras; 2 | 3 | import com.modestmaps.Map; 4 | import com.modestmaps.events.MapEvent; 5 | import com.modestmaps.geo.Location; 6 | import openfl.display.Sprite; 7 | import openfl.geom.Point; 8 | import openfl.text.TextField; 9 | import openfl.text.TextFormat; 10 | 11 | 12 | class MapScale extends Sprite 13 | { 14 | private var map : Map; 15 | 16 | private var leftField : TextField; 17 | private var rightField : TextField; 18 | 19 | private var offsetX : Float; 20 | 21 | public function new(map : Map, offsetX : Float = 0) 22 | { 23 | super(); 24 | this.map = map; 25 | 26 | this.offsetX = offsetX; 27 | 28 | leftField = new TextField(); 29 | leftField.defaultTextFormat = new TextFormat("Arial", 10, 0x000000, false, null, null, null, "_blank"); 30 | leftField.mouseEnabled = leftField.selectable = false; 31 | addChild(leftField); 32 | 33 | rightField = new TextField(); 34 | rightField.defaultTextFormat = new TextFormat("Arial", 10, 0x000000, false, null, null, null, "_blank"); 35 | rightField.mouseEnabled = rightField.selectable = false; 36 | addChild(rightField); 37 | 38 | map.addEventListener(MapEvent.EXTENT_CHANGED, redraw); 39 | map.addEventListener(MapEvent.STOP_ZOOMING, redraw); 40 | map.addEventListener(MapEvent.STOP_PANNING, redraw); 41 | map.addEventListener(MapEvent.RESIZED, onMapResized); 42 | 43 | redraw(null); 44 | } 45 | 46 | private function redraw(event : MapEvent) : Void 47 | { 48 | var pixelWidth : Float = 100; 49 | 50 | // pick two points on the map, 150px apart 51 | var p1 : Point = new Point(map.getWidth() / 2 - pixelWidth / 2, map.getHeight() / 2); 52 | var p2 : Point = new Point(map.getWidth() / 2 + pixelWidth / 2, map.getHeight() / 2); 53 | 54 | var start : Location = map.pointLocation(p1); 55 | var end : Location = map.pointLocation(p2); 56 | 57 | var barParams : Array = [ 58 | { 59 | radius : Distance.R_MILES, 60 | unit : "mile", 61 | units : "miles", 62 | field : leftField, 63 | 64 | }, 65 | { 66 | radius : Distance.R_KM, 67 | unit : "km", 68 | units : "km", 69 | field : rightField, 70 | 71 | }]; 72 | 73 | graphics.clear(); 74 | for (i in 0...barParams.length) 75 | { 76 | 77 | var d : Float = Distance.approxDistance(start, end, barParams[i].radius); 78 | 79 | var metersPerPixel : Float = d / pixelWidth; 80 | 81 | // powers of ten, two? 82 | var nearestPower:Float = Math.pow(2, Math.round(Math.log(d) / Map.LN2)); 83 | //var nearestPower : Float = Std.parseFloat(d.toPrecision(1)); 84 | 85 | 86 | var pixels : Float = nearestPower / metersPerPixel; 87 | 88 | graphics.lineStyle(0, 0x000000); 89 | graphics.beginFill(0xffffff); 90 | graphics.drawRect(0, i * 12, pixels, 5); 91 | 92 | var decDigits : Int = nearestPower < (1) ? 2 : 0; 93 | var unit : String = toFixed(nearestPower,decDigits) == ("1") ? barParams[i].unit : barParams[i].units; 94 | 95 | var field : TextField = barParams[i].field; 96 | 97 | field.text = toFixed(nearestPower,decDigits) + " " + unit; 98 | field.width = field.textWidth + 4; 99 | field.height = field.textHeight + 4; 100 | 101 | field.x = pixels + 2; 102 | field.y = (i * 12) + 2.5 - field.height / 2; 103 | } 104 | 105 | onMapResized(null); 106 | } 107 | 108 | private function onMapResized(event : MapEvent) : Void 109 | { 110 | this.x = 15 + offsetX; 111 | this.y = map.getHeight() - this.height - 6; 112 | } 113 | 114 | private static function toFixed(x:Float, decimalPlaces:Int):String 115 | { 116 | var f = Reflect.field(x, "toFixed"); 117 | return Reflect.callMethod(x, f, [decimalPlaces]); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/AbstractMapProvider.hx: -------------------------------------------------------------------------------- 1 | /** 2 | * vim:et sts=4 sw=4 cindent: 3 | * @ignore 4 | * 5 | * @author darren 6 | * @author migurski 7 | * $Id$ 8 | * 9 | * AbstractMapProvider is the base class for all MapProviders. 10 | * 11 | * @description AbstractMapProvider is the base class for all 12 | * MapProviders. MapProviders are primarily responsible 13 | * for "painting" map Tiles with the correct 14 | * graphic imagery. 15 | */ 16 | 17 | package com.modestmaps.mapproviders; 18 | 19 | import com.modestmaps.core.Coordinate; 20 | import com.modestmaps.geo.IProjection; 21 | import com.modestmaps.geo.Location; 22 | import com.modestmaps.geo.MercatorProjection; 23 | import com.modestmaps.geo.Transformation; 24 | 25 | class AbstractMapProvider 26 | { 27 | public var tileWidth(get, never) : Int; 28 | public var tileHeight(get, never) : Int; 29 | 30 | private static inline var MIN_ZOOM : Int = 1; 31 | private static inline var MAX_ZOOM : Int = 20; 32 | 33 | private var __projection : IProjection; 34 | 35 | // boundaries for the current provider 36 | private var __topLeftOutLimit : Coordinate; 37 | private var __bottomRightInLimit : Coordinate; 38 | 39 | /* 40 | * Abstract constructor, should not be instantiated directly. 41 | */ 42 | public function new(minZoom : Int = MIN_ZOOM, maxZoom : Int = MAX_ZOOM) 43 | { 44 | // see: http://modestmaps.mapstraction.com/trac/wiki/TileCoordinateComparisons#TileGeolocations 45 | var t : Transformation = new Transformation(1.068070779e7, 0, 3.355443185e7, 46 | 0, -1.068070890e7, 3.355443057e7); 47 | 48 | __projection = new MercatorProjection(26, t); 49 | 50 | __topLeftOutLimit = new Coordinate(0, Math.NEGATIVE_INFINITY, minZoom); 51 | __bottomRightInLimit = (new Coordinate(1, Math.POSITIVE_INFINITY, 0)).zoomTo(maxZoom); 52 | } 53 | 54 | /* 55 | * String signature of the current map provider's geometric behavior. 56 | */ 57 | public function geometry() : String 58 | { 59 | return Std.string(__projection); 60 | } 61 | 62 | /** 63 | * Wraps the column around the earth, doesn't touch the row. 64 | * 65 | * Row coordinates shouldn't be outside of outerLimits, 66 | * so we shouldn't need to worry about them here. 67 | * 68 | * @param coord The Coordinate to wrap. 69 | */ 70 | public function sourceCoordinate(coord : Coordinate) : Coordinate 71 | { 72 | var wrappedColumn : Float = coord.column % Math.pow(2, coord.zoom); 73 | 74 | while (wrappedColumn < 0) 75 | { 76 | wrappedColumn += Math.pow(2, coord.zoom); 77 | } // we don't wrap rows here because the map/grid should be enforcing outerLimits :) 78 | 79 | return new Coordinate(coord.row, wrappedColumn, coord.zoom); 80 | } 81 | 82 | /** 83 | * Get top left outer-zoom limit and bottom right inner-zoom limits, 84 | * as Coordinates in a two element array. 85 | */ 86 | public function outerLimits() : Array 87 | { 88 | return [__topLeftOutLimit.copy(), __bottomRightInLimit.copy()]; 89 | } 90 | 91 | /* 92 | * Return projected and transformed coordinate for a location. 93 | */ 94 | public function locationCoordinate(location : Location) : Coordinate 95 | { 96 | return __projection.locationCoordinate(location); 97 | } 98 | 99 | /* 100 | * Return untransformed and unprojected location for a coordinate. 101 | */ 102 | public function coordinateLocation(coordinate : Coordinate) : Location 103 | { 104 | return __projection.coordinateLocation(coordinate); 105 | } 106 | 107 | private function get_tileWidth() : Int 108 | { 109 | return 256; 110 | } 111 | 112 | private function get_tileHeight() : Int 113 | { 114 | return 256; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /com/modestmaps/extras/GreatCircleOverlay.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.extras; 2 | 3 | import com.modestmaps.Map; 4 | import com.modestmaps.core.MapExtent; 5 | import com.modestmaps.extras.LineStyle; 6 | import com.modestmaps.extras.Overlay; 7 | import com.modestmaps.geo.Location; 8 | import openfl.display.Sprite; 9 | import openfl.geom.Point; 10 | import openfl.utils.Dictionary; 11 | 12 | 13 | //import openfl.filters.DropShadowFilter; 14 | 15 | /** 16 | * a subclass of overlay that will render dashed great-circle arcs 17 | */ 18 | class GreatCircleOverlay extends Overlay 19 | { 20 | public var lines : Array> = []; 21 | private var styles : Dictionary = new Dictionary(); 22 | 23 | public function new(map : Map) 24 | { 25 | super(map); 26 | } 27 | 28 | override public function redraw(sprite : Sprite) : Void 29 | { 30 | sprite.graphics.clear(); 31 | for (line in lines) 32 | { 33 | var lineStyle : LineStyle = cast(styles[line],lineStyle)); 34 | var p : Point = map.locationPoint(cast(line[0], Location), sprite); 35 | sprite.graphics.moveTo(p.x, p.y); 36 | var i : Int = 0; 37 | var prev : Location; 38 | for (location in line.substring(1)) 39 | { 40 | var thickness : Float = Math.min(1, 1 - Math.abs(i - (line.length / 2)) / (line.length / 3)); 41 | /* if (i % 4 == 0 && i != line.length-1) { 42 | sprite.graphics.lineStyle(); 43 | } 44 | else { 45 | lineStyle.apply(sprite.graphics, 1+thickness); 46 | } */ 47 | lineStyle.apply(sprite.graphics, 1 + thickness); 48 | p = map.locationPoint(location, sprite); 49 | if (prev != null && (Math.abs(prev.lat - location.lat) > 10 || Math.abs(prev.lon - location.lon) > 10)) 50 | { 51 | sprite.graphics.moveTo(p.x, p.y); 52 | } 53 | else 54 | { 55 | sprite.graphics.lineTo(p.x, p.y); 56 | } 57 | i++; 58 | prev = location; 59 | } 60 | } 61 | } 62 | 63 | public function addGreatCircle(start : Location, end : Location, lineStyle : LineStyle = null) : MapExtent 64 | { 65 | 66 | var extent : MapExtent = new MapExtent(); 67 | var latlngs : Array = []; 68 | 69 | with(Math); { 70 | 71 | var lat1 : Float = start.lat * PI / 180.0; 72 | var lon1 : Float = start.lon * PI / 180.0; 73 | var lat2 : Float = end.lat * PI / 180.0; 74 | var lon2 : Float = end.lon * PI / 180.0; 75 | 76 | var d : Float = 2 * asin(sqrt(pow((sin((lat1 - lat2) / 2)), 2) + cos(lat1) * cos(lat2) * pow((sin((lon1 - lon2) / 2)), 2))); 77 | var bearing : Float = atan2(sin(lon1 - lon2) * cos(lat2), cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(lon1 - lon2)) / -(PI / 180); 78 | bearing = bearing < (0) ? 360 + bearing : bearing; 79 | 80 | var numSegments : Int = as3hx.Compat.parseInt(40 + (400 * Distance.approxDistance(start, end) / (Math.PI * 2 * 6378000))); 81 | for (n in 0...numSegments) 82 | { 83 | var f : Float = (1 / (numSegments - 1)) * n; 84 | var A : Float = sin((1 - f) * d) / sin(d); 85 | var B : Float = sin(f * d) / sin(d); 86 | var x : Float = A * cos(lat1) * cos(lon1) + B * cos(lat2) * cos(lon2); 87 | var y : Float = A * cos(lat1) * sin(lon1) + B * cos(lat2) * sin(lon2); 88 | var z : Float = A * sin(lat1) + B * sin(lat2); 89 | 90 | var latN : Float = atan2(z, sqrt(pow(x, 2) + pow(y, 2))); 91 | var lonN : Float = atan2(y, x); 92 | var l : Location = new Location(latN / (PI / 180), lonN / (PI / 180)); 93 | latlngs.push(l); 94 | extent.enclose(l); 95 | } 96 | } 97 | 98 | lines.push(latlngs); 99 | 100 | styles.set(latlngs, (lineStyle != null ? lineStyle : new LineStyle())); 101 | 102 | refresh(); 103 | 104 | return extent; 105 | } 106 | } 107 | 108 | -------------------------------------------------------------------------------- /samples/ModestMapsSample/src/DemoMarkers.hx: -------------------------------------------------------------------------------- 1 | package; 2 | import com.modestmaps.Map; 3 | import com.modestmaps.core.MapExtent; 4 | import com.modestmaps.events.MarkerEvent; 5 | import com.modestmaps.geo.Location; 6 | import openfl.geom.Point; 7 | import openfl.text.TextField; 8 | 9 | /** 10 | * ... 11 | * @author Marc Mauri 12 | */ 13 | class DemoMarkers 14 | { 15 | 16 | // a tooltip/flag that appears on marker rollover 17 | private var _tooltip : Tooltip; 18 | private var _parent : Main; 19 | 20 | 21 | 22 | public function new(parent : Main) 23 | { 24 | _parent = parent; 25 | _tooltip = new Tooltip(); 26 | parent.map.addChild(_tooltip); 27 | parent.map.addEventListener(MarkerEvent.MARKER_CLICK, onMarkerClick); 28 | parent.map.addEventListener(MarkerEvent.MARKER_ROLL_OVER, onMarkerRollOver); 29 | parent.map.addEventListener(MarkerEvent.MARKER_ROLL_OUT, onMarkerRollOut); 30 | } 31 | 32 | public function placeMarkers():Void 33 | { 34 | // Some sample data 35 | // In most cases, we would have loaded this from XML, or a web service. 36 | var markerpoints = [ 37 | { title:'Rochdale', loc:"37.865571, -122.259679"}, 38 | { title:'Parker Ave.', loc:"37.780492, -122.453731"}, 39 | { title:'Pepper Dr.', loc:"37.623443, -122.426577"}, 40 | { title:'3rd St.', loc:"37.779297, -122.392877"}, 41 | { title:'Divisadero St.', loc:"37.771919, -122.437413"}, 42 | { title:'Market St.', loc:"37.812734, -122.280064"}, 43 | { title:'17th St. is a long street with a short name, but we want to test the tooltip with a long title.', loc:"37.804274, -122.262940"} 44 | ]; 45 | 46 | var o:Dynamic; 47 | 48 | // Now, we just loop through our data set, and place the markers 49 | for (o in markerpoints) 50 | { 51 | 52 | // step 1 - create a marker 53 | var marker:SampleMarker = new SampleMarker(); 54 | 55 | // step 2 - give it any custom app-specific data it might need 56 | marker.title = o.title; 57 | 58 | // step 3 - create a location object 59 | // 60 | // if you have lat and long... 61 | // var loc:Location = new Location (lat, long); 62 | // 63 | // but, we have a comma-separated lat/long pair, so... 64 | var loc:Location = Location.fromString( o.loc ); 65 | 66 | // step 4 - put the marker on the map 67 | _parent.map.putMarker( loc, marker); 68 | } 69 | _parent.map.tweenExtent(new MapExtent(37.829853, 37.700121, -122.212601, -122.514725),3); 70 | } 71 | 72 | /** 73 | * Marker Click 74 | */ 75 | private function onMarkerClick(event:MarkerEvent):Void 76 | { 77 | var marker:SampleMarker = cast(event.marker,SampleMarker); 78 | _parent.status.text = "Marker Clicked: " + marker.title + " " + event.location; 79 | } 80 | 81 | /** 82 | * Marker Roll Over 83 | */ 84 | private function onMarkerRollOver(event:MarkerEvent):Void 85 | { 86 | trace('Roll Over ' + event.marker + event.location); 87 | var marker:SampleMarker = cast(event.marker,SampleMarker); 88 | 89 | // show tooltip 90 | var pt:Point = _parent.map.locationPoint( event.location, _parent.map); 91 | _tooltip.x = pt.x; 92 | _tooltip.y = pt.y; 93 | _tooltip.label = marker.title; 94 | _tooltip.visible = true; 95 | } 96 | 97 | /** 98 | * Marker Roll Out 99 | */ 100 | private function onMarkerRollOut(event:MarkerEvent):Void 101 | { 102 | // hide the tooltip 103 | _tooltip.visible = false; 104 | } 105 | 106 | public function dispose(): Void 107 | { 108 | _parent.map.removeEventListener(MarkerEvent.MARKER_CLICK, onMarkerClick); 109 | _parent.map.removeEventListener(MarkerEvent.MARKER_ROLL_OVER, onMarkerRollOver); 110 | _parent.map.removeEventListener(MarkerEvent.MARKER_ROLL_OUT, onMarkerRollOut); 111 | _parent.map.removeChild(_tooltip); 112 | } 113 | } -------------------------------------------------------------------------------- /samples/old_ModestMapsExamples/src/HelloCustomTiles.hx: -------------------------------------------------------------------------------- 1 | import com.adobe.viewsource.ViewSource; 2 | import com.modestmaps.Map; 3 | import com.modestmaps.TweenMap; 4 | import com.modestmaps.extras.MapControls; 5 | import com.modestmaps.extras.ZoomSlider; 6 | import com.modestmaps.geo.Location; 7 | 8 | import flash.display.Sprite; 9 | import flash.display.StageAlign; 10 | import flash.display.StageScaleMode; 11 | import flash.events.Event; 12 | import flash.events.MouseEvent; 13 | 14 | @:meta(SWF(backgroundColor="#808080")) 15 | 16 | 17 | 18 | import com.modestmaps.core.Tile; 19 | import com.modestmaps.core.Coordinate; 20 | import com.modestmaps.mapproviders.IMapProvider; 21 | import com.modestmaps.mapproviders.AbstractMapProvider; 22 | 23 | class HelloCustomTiles extends Sprite 24 | { 25 | public var map : Map; 26 | 27 | public function new() 28 | { 29 | super(); 30 | stage.align = StageAlign.TOP_LEFT; 31 | stage.scaleMode = StageScaleMode.NO_SCALE; 32 | 33 | ViewSource.addMenuItem(this, "srcview/index.html", true); 34 | 35 | // make a draggable TweenMap so that we have smooth zooming and panning animation 36 | // use our blank provider, defined below: 37 | map = new TweenMap(stage.stageWidth, stage.stageHeight, true, new BlankProvider()); 38 | map.addEventListener(MouseEvent.DOUBLE_CLICK, map.onDoubleClick); 39 | addChild(map); 40 | 41 | map.addChild(map.grid.debugField); 42 | 43 | // tell the map grid to make tiles using our custom class, defined below: 44 | map.grid.setTileClass(CustomTile); 45 | 46 | // add some basic controls 47 | // you're free to use these, but I'd make my own if I was a Flash coder :) 48 | map.addChild(new MapControls(map, true, true)); 49 | map.addChild(new ZoomSlider(map)); 50 | 51 | // start at 0,0 52 | // 11 seems like a good zoom level... 53 | map.setCenterZoom(new Location(0, 0), 11); 54 | 55 | // make sure the map always fills the screen: 56 | stage.addEventListener(Event.RESIZE, onStageResize); 57 | } 58 | 59 | public function onStageResize(event : Event) : Void 60 | { 61 | map.setSize(stage.stageWidth, stage.stageHeight); 62 | } 63 | } 64 | 65 | 66 | 67 | class CustomTile extends Tile 68 | { 69 | public function new(column : Int, row : Int, zoom : Int) 70 | { 71 | super(column, row, zoom); 72 | } 73 | 74 | override public function init(column : Int, row : Int, zoom : Int) : Void 75 | { 76 | super.init(column, row, zoom); 77 | 78 | graphics.clear(); 79 | graphics.beginFill(0xffffff); 80 | graphics.drawRect(0, 0, 32, 32); 81 | graphics.endFill(); 82 | 83 | var r : Int = Math.random() * 255; 84 | var g : Int = Math.random() * 255; 85 | var b : Int = Math.random() * 255; 86 | 87 | var c : Int = 0xff000000 | r << 16 | g << 8 | b; 88 | 89 | graphics.beginFill(c); 90 | graphics.drawCircle(16, 16, 8); 91 | graphics.endFill(); 92 | } 93 | } 94 | 95 | class BlankProvider extends AbstractMapProvider implements IMapProvider 96 | { 97 | public function getTileUrls(coord : Coordinate) : Array 98 | { 99 | return []; 100 | } 101 | 102 | public function toString() : String 103 | { 104 | return "BLANK_PROVIDER"; 105 | } 106 | 107 | override private function get_TileWidth() : Float 108 | { 109 | return 32; 110 | } 111 | 112 | override private function get_TileHeight() : Float 113 | { 114 | return 32; 115 | } 116 | 117 | public function new() 118 | { 119 | super(); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /docs/com/modestmaps/core/package-detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.modestmaps.core Summary 8 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 |
32 |
33 |
34 |
35 | 36 |
Classes
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 |
 ClassDescription
 Coordinate 
 MapExtent 
 Tile 
 TileGrid 
 TweenTile 
57 |

58 |
59 |

60 | 62 |
63 |
64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/AbstractZoomifyMapProvider.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.mapproviders; 2 | 3 | import com.modestmaps.core.Coordinate; 4 | import com.modestmaps.mapproviders.IMapProvider; 5 | 6 | 7 | /** 8 | * @author migurski 9 | * $Id$ 10 | */ 11 | 12 | class AbstractZoomifyMapProvider extends AbstractMapProvider implements IMapProvider 13 | { 14 | private var __baseDirectory : String; 15 | private var __groups : Array; 16 | public static inline var LN2 = 0.6931471805599453; 17 | 18 | public function new() 19 | { 20 | super(); 21 | } 22 | 23 | public function toString() : String 24 | { 25 | return "ABSTRACT_ZOOMIFY"; 26 | } 27 | 28 | /** 29 | * Zoomifyer EZ (download: http://www.zoomify.com/express.htm) cuts a base 30 | * image into tiles, and creates a metadata file named ImageProperties.xml 31 | * in the same directory. Instead of parsing that file, pass the relevant 32 | * bits to this method. Base directory *must* have a trailing slash. 33 | * 34 | * Example: 35 | * 36 | * ImageProperties.xml content: 37 | * 38 | * 39 | * URL of ImageProperties.xml: 40 | * http://example.com/ImageProperties.xml 41 | * 42 | * Corresponding call to defineImageProperties(): 43 | * defineImageProperties('http://example.com/', 11258, 7085); 44 | * 45 | * Tiles created by Zoomifyer EZ are placed in folders named "TileGroup{0..n}", 46 | * in groups of 256, so we need to quickly iterate through the entire set of 47 | * tile coordinates to determine where the group boundaries are. These are 48 | * stored in the __groups array. 49 | */ 50 | private function defineImageProperties(baseDirectory : String, width : Float, height : Float) : Void 51 | { 52 | __baseDirectory = baseDirectory; 53 | 54 | var zoom : Float = Math.ceil(Math.log(Math.max(width, height)) / LN2); 55 | 56 | __topLeftOutLimit = new Coordinate(0, 0, 0); 57 | __bottomRightInLimit = (new Coordinate(height, width, zoom)).zoomTo(zoom - 8); 58 | 59 | __groups = []; 60 | var i : Float = 0; 61 | 62 | /* 63 | * Iterate over all possible tiles in order: left to right, top to 64 | * bottom, zoomed-out to zoomed-in. Note the first tile coordinate 65 | * in each group of 256. 66 | */ 67 | var c : Coordinate = __topLeftOutLimit.copy(); 68 | while (c.zoom <= __bottomRightInLimit.zoom) 69 | { 70 | 71 | // edges of the image at current zoom level 72 | var tlo : Coordinate = __topLeftOutLimit.zoomTo(c.zoom); 73 | var bri : Coordinate = __bottomRightInLimit.zoomTo(c.zoom); 74 | 75 | // left-to-right, top-to-bottom, like reading a book 76 | c.row = tlo.row; 77 | while (c.row <= bri.row) 78 | { 79 | c.column = tlo.column; 80 | while (c.column <= bri.column) 81 | { 82 | 83 | // zoomify groups tiles into folders of 256 each 84 | if (i % 256 == 0) 85 | __groups.push(c.copy()); 86 | 87 | i += 1; 88 | c.column += 1; 89 | } 90 | c.row += 1; 91 | } 92 | c.zoom += 1; 93 | } 94 | } 95 | 96 | private function coordinateGroup(c : Coordinate) : Float 97 | { 98 | var i : Int = 0; 99 | while (i < __groups.length) 100 | { 101 | if (i + 1 == __groups.length) 102 | return i; 103 | 104 | var g : Coordinate = __groups[i + 1].copy(); 105 | 106 | if (c.zoom < g.zoom || (c.zoom == g.zoom && (c.row < g.row || (c.row == g.row && c.column < g.column)))) 107 | return i; 108 | i += 1; 109 | } 110 | return -1; 111 | } 112 | 113 | public function getTileUrls(coord : Coordinate) : Array 114 | { 115 | return [__baseDirectory + "TileGroup" + coordinateGroup(coord) + "/" + (coord.zoom) + "-" + (coord.column) + "-" + (coord.row) + ".jpg"]; 116 | } 117 | } 118 | 119 | -------------------------------------------------------------------------------- /docs/com/modestmaps/mapproviders/yahoo/package-detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.modestmaps.mapproviders.yahoo Summary 8 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 |
32 |
33 |
34 |
35 | 36 |
Classes
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 |
 ClassDescription
 YahooAerialMapProvider 
 YahooHybridMapProvider 
 YahooOverlayMapProvider 
 YahooRoadMapProvider 
54 |

55 |
56 |

57 | 59 |
60 |
61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /docs/com/modestmaps/mapproviders/microsoft/package-detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.modestmaps.mapproviders.microsoft Summary 8 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 |
32 |
33 |
34 |
35 | 36 |
Classes
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 |
 ClassDescription
 MicrosoftAerialMapProvider 
 MicrosoftHybridMapProvider 
 MicrosoftProvider 
 MicrosoftRoadMapProvider 
54 |

55 |
56 |

57 | 59 |
60 |
61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /samples/old_ModestMapsExamples/src/HelloESRI.hx: -------------------------------------------------------------------------------- 1 | 2 | import com.adobe.viewsource.ViewSource; 3 | import com.modestmaps.Map; 4 | import com.modestmaps.TweenMap; 5 | import com.modestmaps.core.MapExtent; 6 | import com.modestmaps.extras.MapControls; 7 | import com.modestmaps.geo.Location; 8 | import com.modestmaps.mapproviders.IMapProvider; 9 | 10 | import flash.display.Sprite; 11 | import flash.display.StageAlign; 12 | import flash.display.StageScaleMode; 13 | import flash.events.Event; 14 | import flash.events.MouseEvent; 15 | 16 | @:meta(SWF(backgroundColor="#eeeeee")) 17 | 18 | 19 | import com.modestmaps.core.Coordinate; 20 | import com.modestmaps.mapproviders.AbstractMapProvider; 21 | 22 | import com.modestmaps.geo.LinearProjection; 23 | import com.modestmaps.geo.Transformation; 24 | import flash.display.Shape; 25 | 26 | class HelloESRI extends Sprite 27 | { 28 | public var map : Map; 29 | 30 | public function new() 31 | { 32 | super(); 33 | stage.align = StageAlign.TOP_LEFT; 34 | stage.scaleMode = StageScaleMode.NO_SCALE; 35 | 36 | ViewSource.addMenuItem(this, "srcview/index.html", true); 37 | 38 | map = new TweenMap(stage.stageWidth, stage.stageHeight, true, new EsriMapProvider(), new MapExtent(48.383, 43.300, 5.367, -4.500)); 39 | map.addEventListener(MouseEvent.DOUBLE_CLICK, map.onDoubleClick); 40 | addChild(map); 41 | 42 | map.putMarker(new Location(51.50757, -0.1078), new Marker()); 43 | map.putMarker(new Location(50.4363, 30.5390), new Marker()); 44 | map.putMarker(new Location(37.47794, -122.15110), new Marker()); 45 | 46 | map.addChild(new MapControls(map)); 47 | 48 | stage.addEventListener(Event.RESIZE, onStageResize); 49 | } 50 | 51 | private function onStageResize(event : Event) : Void 52 | { 53 | map.setSize(stage.stageWidth, stage.stageHeight); 54 | } 55 | } 56 | 57 | 58 | 59 | class Marker extends Shape 60 | { 61 | public function new() 62 | { 63 | super(); 64 | graphics.beginFill(0xff0000); 65 | graphics.drawCircle(0, 0, 10); 66 | graphics.endFill(); 67 | } 68 | } 69 | 70 | class EsriMapProvider extends AbstractMapProvider implements IMapProvider 71 | { 72 | public function new(minZoom : Int = MIN_ZOOM, maxZoom : Int = MAX_ZOOM) 73 | { 74 | super(0, Math.min(14, maxZoom)); 75 | 76 | var t : Transformation = new Transformation(0.3183098861837907, 0, 1, 77 | 0, -0.3183098861837907, 0.5); 78 | 79 | __projection = new LinearProjection(0, t); 80 | } 81 | 82 | public function toString() : String 83 | { 84 | return "ESRI"; 85 | } 86 | 87 | public function getTileUrls(coord : Coordinate) : Array 88 | { 89 | return ["http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/tile/" + getZoomString(coord)]; 90 | } 91 | 92 | private function getZoomString(coord : Coordinate) : String 93 | { 94 | var sourceCoord : Coordinate = sourceCoordinate(coord); 95 | return (sourceCoord.zoom) + "/" + (sourceCoord.row) + "/" + (sourceCoord.column); 96 | } 97 | 98 | override public function sourceCoordinate(coord : Coordinate) : Coordinate 99 | { 100 | var tilesWide : Int = Math.pow(2, coord.zoom + 1); 101 | 102 | var wrappedColumn : Float = coord.column % tilesWide; 103 | 104 | while (wrappedColumn < 0) 105 | { 106 | wrappedColumn += tilesWide; 107 | } // we don't wrap rows here because the map/grid should be enforcing outerLimits :) 108 | 109 | 110 | 111 | 112 | return new Coordinate(coord.row, wrappedColumn, coord.zoom); 113 | } 114 | 115 | override private function get_TileWidth() : Float 116 | { 117 | return 512; 118 | } 119 | 120 | override private function get_TileHeight() : Float 121 | { 122 | return 512; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /com/modestmaps/mapproviders/WMSMapProvider.hx: -------------------------------------------------------------------------------- 1 | /** 2 | * MapProvider for a WMS server, in either EPSG:4326 or EPSG:900913 3 | */ 4 | package com.modestmaps.mapproviders; 5 | 6 | import com.modestmaps.core.Coordinate; 7 | import com.modestmaps.geo.LinearProjection; 8 | import com.modestmaps.geo.Location; 9 | import com.modestmaps.geo.Transformation; 10 | import nme.errors.Error; 11 | import openfl.net.URLVariables; 12 | 13 | 14 | 15 | class WMSMapProvider extends AbstractMapProvider implements IMapProvider 16 | { 17 | 18 | public static inline var EPSG_4326 : String = "EPSG:4326"; 19 | public static inline var EPSG_900913 : String = "EPSG:900913"; 20 | 21 | public static var DEFAULT_PARAMS : Dynamic = 22 | { 23 | LAYERS : "0,1", 24 | FORMAT : "image/png", 25 | VERSION : "1.1.1", 26 | SERVICE : "WMS", 27 | REQUEST : "GetMap", 28 | SRS : "EPSG:4326", 29 | WIDTH : "256", 30 | HEIGHT : "256", 31 | 32 | }; 33 | 34 | private var serverUrl : String; 35 | private var wmsParams : Dynamic; 36 | private var wms : String; 37 | 38 | public function new(serverURL : String, wmsParams : Dynamic = null) 39 | { 40 | super(); 41 | 42 | if (wmsParams == null) wmsParams = DEFAULT_PARAMS; 43 | 44 | this.serverUrl = serverURL; 45 | this.wmsParams = wmsParams; 46 | 47 | var data : URLVariables = new URLVariables(); 48 | for (param in Reflect.fields(wmsParams)) 49 | { 50 | Reflect.setField(data, param, Reflect.field(wmsParams, param)); 51 | } 52 | this.wms = "?" + Std.string(data); 53 | 54 | if (Reflect.field(wmsParams, "SRS") == EPSG_4326) 55 | { 56 | var t : Transformation = new Transformation(166886.05360752725, 0, 524288, 0, -166886.05360752725, 524288); 57 | __projection = new LinearProjection(20, t); 58 | } 59 | else if (Reflect.field(wmsParams, "SRS") && Reflect.field(wmsParams, "SRS") != EPSG_900913) 60 | { 61 | throw new Error("[WMSMapProvider] Only Linear and (Google-style) Mercator projections are currently supported"); 62 | } 63 | } 64 | 65 | public function getTileUrls(coord : Coordinate) : Array 66 | { 67 | var worldSize : Int = Math.pow(2, coord.zoom); 68 | // FIXME: check this for lat-lon projection, it's probably wrong 69 | if (coord.row < 0 || coord.row >= worldSize) 70 | { 71 | return []; 72 | } 73 | 74 | var sourceCoord : Coordinate = sourceCoordinate(coord); 75 | var bottomLeftCoord : Coordinate = sourceCoord.down(); 76 | var topRightCoord : Coordinate = sourceCoord.right(); 77 | 78 | var boundingBox : String; 79 | 80 | if (Reflect.field(wmsParams, "SRS") == EPSG_4326) 81 | { 82 | // lat-lon is easy? 83 | var bottomLeftLocation : Location = coordinateLocation(bottomLeftCoord); 84 | var topRightLocation : Location = coordinateLocation(topRightCoord); 85 | boundingBox = "&BBOX=" + [bottomLeftLocation.lon.toFixed(5), 86 | bottomLeftLocation.lat.toFixed(5), 87 | topRightLocation.lon.toFixed(5), 88 | topRightLocation.lat.toFixed(5)].join(","); 89 | return [serverUrl + wms + boundingBox]; 90 | } // ...don't ask me, I just read http://wiki.osgeo.org/wiki/WMS_Tiling_Client_Recommendation#Tile_Grid_Definition // they get us into the raw mercator-ish units that WMS servers expect // these are magic numbers derived from the approx. radius of the earth in meters // the following only works for EPSG_900913... 91 | 92 | var quadrantWidth : Float = 20037508.34; 93 | var magicZoom : Float = Math.log(2 * quadrantWidth) / Math.LN2; 94 | 95 | // apply that number os a zoom, it's basically getting us tile coordinates for zoom level 25.something... 96 | bottomLeftCoord = bottomLeftCoord.zoomTo(magicZoom); 97 | topRightCoord = topRightCoord.zoomTo(magicZoom); 98 | 99 | // flip and offset so we have correct minx,miny,maxx,maxy 100 | var minx : Float = bottomLeftCoord.column - quadrantWidth; 101 | var miny : Float = quadrantWidth - bottomLeftCoord.row; 102 | var maxx : Float = topRightCoord.column - quadrantWidth; 103 | var maxy : Float = quadrantWidth - topRightCoord.row; 104 | 105 | boundingBox = "&BBOX=" + [minx.toFixed(5), miny.toFixed(5), maxx.toFixed(5), maxy.toFixed(5)].join(","); 106 | 107 | return [serverUrl + wms + boundingBox]; 108 | } 109 | 110 | public function toString() : String 111 | { 112 | return "WMS"; 113 | } 114 | } 115 | 116 | -------------------------------------------------------------------------------- /docs/title-bar.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Adobe Flex 2 Language Reference 8 | 9 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 29 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
API Documentation 26 | All Packages | All Classes | Index | No Frames   27 | 30 |

31 |
 
 
51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /docs/com/modestmaps/geo/package-detail.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.modestmaps.geo Summary 8 | 9 | 10 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 |
32 |
33 |
34 |
35 | 36 |
Interfaces
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 |
 InterfaceDescription
 IProjection 
45 | 46 |
Classes
47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |
 ClassDescription
 AbstractProjection 
 LinearProjection 
 Location 
 MercatorProjection 
 Transformation 
67 |

68 |
69 |

70 | 72 |
73 |
74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /com/modestmaps/extras/HandCursor.hx: -------------------------------------------------------------------------------- 1 | package com.modestmaps.extras; 2 | 3 | import com.modestmaps.Map; 4 | import com.modestmaps.extras.HandDown; 5 | import com.modestmaps.extras.HandUp; 6 | import openfl.display.Bitmap; 7 | import openfl.display.Sprite; 8 | import openfl.events.Event; 9 | import openfl.events.MouseEvent; 10 | import openfl.filters.DropShadowFilter; 11 | import openfl.ui.Mouse; 12 | 13 | 14 | 15 | class HandCursor extends Sprite 16 | { 17 | @:meta(Embed(source="hand.png")) 18 | 19 | private var HandUp : Class; 20 | 21 | @:meta(Embed(source="hand_down.png")) 22 | 23 | private var HandDown : Class; 24 | 25 | private var map : Map; 26 | private var enabled : Bool = false; 27 | private var hand : Sprite; 28 | private var handup : Bitmap; 29 | private var handdown : Bitmap; 30 | 31 | private var callbacks : Array = []; 32 | 33 | public function new(map : Map) 34 | { 35 | super(); 36 | this.map = map; 37 | 38 | mouseEnabled = false; 39 | cacheAsBitmap = true; 40 | mouseChildren = false; 41 | 42 | hand = new Sprite(); 43 | 44 | handup = cast(Type.createInstance(HandUp, []), Bitmap); 45 | hand.addChild(handup); 46 | handdown = cast(Type.createInstance(HandDown, []), Bitmap); 47 | 48 | hand.x -= hand.width / 2; 49 | hand.y -= hand.height / 2; 50 | hand.visible = false; 51 | addChild(hand); 52 | 53 | filters = [new DropShadowFilter(1, 45, 0, 1, 3, 3, .7, 2)]; 54 | 55 | addEventListener(Event.ADDED_TO_STAGE, onAddedToStage); 56 | } 57 | 58 | public function onAddedToStage(event : Event) : Void 59 | { 60 | stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); 61 | stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp); 62 | stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); 63 | stage.addEventListener(MouseEvent.CLICK, onMouseClick); 64 | stage.addEventListener(Event.MOUSE_LEAVE, onMouseLeave); 65 | 66 | map.grid.addEventListener(MouseEvent.ROLL_OVER, enable); 67 | map.grid.addEventListener(MouseEvent.ROLL_OUT, disable); 68 | } 69 | public function onRemovedFromStage(event : Event) : Void 70 | { 71 | stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); 72 | stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp); 73 | stage.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); 74 | stage.removeEventListener(MouseEvent.CLICK, onMouseClick); 75 | stage.removeEventListener(Event.MOUSE_LEAVE, onMouseLeave); 76 | 77 | map.grid.removeEventListener(MouseEvent.ROLL_OVER, enable); 78 | map.grid.removeEventListener(MouseEvent.ROLL_OUT, disable); 79 | } 80 | 81 | public function onMouseLeave(event : Event) : Void 82 | { 83 | if (enabled) 84 | { 85 | hand.visible = false; 86 | } 87 | } 88 | 89 | public function onMouseMove(event : MouseEvent) : Void 90 | { 91 | if (enabled && !hand.visible) 92 | { 93 | hand.visible = true; 94 | } 95 | x = event.localX; 96 | y = event.localY; 97 | } 98 | 99 | public function onMouseUp(event : MouseEvent) : Void 100 | { 101 | if (enabled) 102 | { 103 | Mouse.hide(); 104 | callNextFrame(Mouse.hide); 105 | } 106 | hand.removeChild(handdown); 107 | hand.addChild(handup); 108 | } 109 | public function onMouseClick(event : MouseEvent) : Void 110 | { 111 | if (enabled) 112 | { 113 | Mouse.hide(); 114 | callNextFrame(Mouse.hide); 115 | } 116 | } 117 | public function onMouseDown(event : MouseEvent) : Void 118 | { 119 | if (enabled) 120 | { 121 | Mouse.hide(); 122 | callNextFrame(Mouse.hide); 123 | } 124 | if (hand.contains(handup)) 125 | { 126 | hand.removeChild(handup); 127 | hand.addChild(handdown); 128 | } 129 | } 130 | 131 | public function enable(event : Event = null) : Void 132 | { 133 | Mouse.hide(); 134 | callNextFrame(Mouse.hide); 135 | hand.visible = true; 136 | enabled = true; 137 | } 138 | public function disable(event : Event = null) : Void 139 | { 140 | Mouse.show(); 141 | callNextFrame(Mouse.show); 142 | hand.visible = false; 143 | enabled = false; 144 | } 145 | 146 | private function callNextFrame(callback : Function) : Void 147 | { 148 | if (!hasEventListener(Event.ENTER_FRAME)) 149 | { 150 | addEventListener(Event.ENTER_FRAME, onEnterFrame); 151 | } 152 | callbacks.push(callback); 153 | } 154 | 155 | private function onEnterFrame(event : Event) : Void 156 | { 157 | while (callbacks.length > 0) 158 | { 159 | var callback : Function = cast(callbacks.shift(), Function); 160 | callback(); 161 | } 162 | removeEventListener(Event.ENTER_FRAME, onEnterFrame); 163 | } 164 | } 165 | --------------------------------------------------------------------------------