Changeset 160
- Timestamp:
- 03/09/07 15:35:52 (2 years ago)
- Files:
-
- branches/api (deleted)
- tags/branchpoint api (deleted)
- trunk/as2/lib/com/modestmaps/core/TileGrid.as (modified) (10 diffs)
- trunk/as2/lib/com/modestmaps/geo/Location.as (modified) (1 diff)
- trunk/as2/lib/com/modestmaps/geo/Map.as (deleted)
- trunk/as2/lib/com/modestmaps/Map.as (copied) (copied from branches/api/as2/lib/com/modestmaps/Map.as)
- trunk/as2/lib/SampleClient.as (modified) (7 diffs)
- trunk/as2/lib/SampleFlashLiteClient.as (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/as2/lib/com/modestmaps/core/TileGrid.as
r144 r160 4 4 */ 5 5 6 import com.modestmaps. geo.Map;6 import com.modestmaps.Map; 7 7 import com.modestmaps.geo.Location; 8 8 import com.modestmaps.core.Coordinate; … … 114 114 public function resetTiles(coord:Coordinate, point:Point):Void 115 115 { 116 if(!tiles) { 117 setInitialTile(coord, point); 118 return; 119 } 120 116 121 var initTile:Tile; 117 122 var condemnedTiles:/*Tile*/Array = activeTiles(); … … 187 192 } 188 193 189 public function putMarker( name:String, coord:Coordinate, location:Location):Marker190 { 191 var marker:Marker = new Marker( name, coord, location);192 //log('Marker '+ name+': '+coord.toString());194 public function putMarker(id:String, coord:Coordinate, location:Location):Marker 195 { 196 var marker:Marker = new Marker(id, coord, location); 197 //log('Marker '+id+': '+coord.toString()); 193 198 markers.put(marker); 194 199 … … 197 202 } 198 203 199 public function removeMarker(name:String):Void 200 { 201 var marker:Marker = markers.getMarker(name); 202 if (marker) 203 { 204 public function removeMarker(id:String):Void 205 { 206 var marker:Marker = markers.getMarker(id); 207 if(marker) 204 208 markers.remove(marker); 205 }206 209 } 207 210 … … 321 324 322 325 if(previousPosition.x != well._x || previousPosition.y != well._y) 323 map.on WellPanned(new Point(well._x - __startingWellPosition.x, well._y - __startingWellPosition.y));326 map.onPanned(new Point(well._x - __startingWellPosition.x, well._y - __startingWellPosition.y)); 324 327 325 328 wellDragTask = Reactor.callNextFrame(Delegate.create(this, this.onWellDrag), new Point(well._x, well._y)); … … 409 412 { 410 413 var point:Point = new Point(0, 0); 414 return pointCoordinate(point); 415 } 416 417 public function centerCoordinate():Coordinate 418 { 419 var point:Point = new Point(width/2, height/2); 411 420 return pointCoordinate(point); 412 421 } … … 490 499 //log('Starting well position: '+__startingWellPosition.toString()); 491 500 492 map.onStart Drag();501 map.onStartPan(); 493 502 well.startDrag(false, xMin, yMin, xMax, yMax); 494 503 onWellDrag(__startingWellPosition.copy()); … … 501 510 private function stopWellDrag():Void 502 511 { 503 map.onStop Drag();512 map.onStopPan(); 504 513 wellDragTask.cancel(); 505 514 well.stopDrag(); … … 965 974 for(var id:String in newOverlappingMarkers) { 966 975 if(newOverlappingMarkers[id] && !__overlappingMarkers[id]) { 967 map.onMarkerEnters( markers.getMarker(id));976 map.onMarkerEnters(id, markers.getMarker(id).location); 968 977 __overlappingMarkers[id] = true; 969 978 } … … 972 981 for(var id:String in __overlappingMarkers) { 973 982 if(!newOverlappingMarkers[id] && __overlappingMarkers[id]) { 974 map.onMarkerLeaves( markers.getMarker(id));983 map.onMarkerLeaves(id, markers.getMarker(id).location); 975 984 delete __overlappingMarkers[id]; 976 985 } trunk/as2/lib/com/modestmaps/geo/Location.as
r57 r160 12 12 public function toString():String 13 13 { 14 return '(' + lat + ',' + lon + ')'; 14 var roundLat:Number = Math.round(lat * 10000) / 10000; 15 var roundLon:Number = Math.round(lon * 10000) / 10000; 16 17 return '('+roundLat+','+roundLon+')'; 15 18 } 16 19 } trunk/as2/lib/SampleClient.as
r143 r160 1 1 import mx.utils.Delegate; 2 2 import com.stamen.twisted.Reactor; 3 import com.modestmaps. geo.Map;3 import com.modestmaps.Map; 4 4 import com.modestmaps.core.TileGrid; 5 5 import com.modestmaps.mapproviders.MapProviders; … … 9 9 class SampleClient 10 10 { 11 private static var __map :Map;12 13 private static var __ mpButtons : MovieClip;11 private static var __map:Map; 12 private static var __mapButtons:MovieClip; 13 private static var __status:TextField; 14 14 15 15 public static function main(clip:MovieClip):Void … … 17 17 Reactor.run(clip, null, 50); 18 18 19 var initObj : Object = 20 { 21 mapProvider: MapProviderFactory.getInstance().getMapProvider(MapProviders.GOOGLE_ROAD), 22 _x: 128, 23 _y: 128, 24 width: Stage.width - 256, 25 height: Stage.height - 256, 26 draggable: true 27 }; 28 29 __map = Map(clip.attachMovie(Map.symbolName, 'map', clip.getNextHighestDepth(), initObj )); 19 __map = Map(clip.attachMovie(Map.symbolName, 'map', clip.getNextHighestDepth())); 20 __map.init(Stage.width-256, Stage.height-256, true, MapProviderFactory.getInstance().getMapProvider(MapProviders.GOOGLE_ROAD)); 21 __map.addEventListener(Map.EVENT_ZOOMED_BY, onZoomed); 22 __map.addEventListener(Map.EVENT_STOP_ZOOMING, onStopZoom); 23 __map.addEventListener(Map.EVENT_PANNED_BY, onPanned); 24 __map.addEventListener(Map.EVENT_STOP_PANNING, onStopPan); 25 __map.addEventListener(Map.EVENT_RESIZED_TO, onResized); 26 27 __status = clip.createTextField('status', clip.getNextHighestDepth(), 0, 0, 600, 100); 28 __status.selectable = false; 29 __status.textColor = 0x000000; 30 __status.text = '...'; 31 __status._height = __status.textHeight + 2; 30 32 31 33 var extent:/*Location*/Array = [new Location(37.829853, -122.514725), 32 34 new Location(37.700121, -122.212601)]; 33 35 34 __map.set InitialExtent(extent);36 __map.setExtent(extent); 35 37 36 38 //Reactor.callLater(2000, Delegate.create(__map, __map.setNewCenter), new Location(37.811411, -122.360916), 14); … … 50 52 Stage.align = 'TL'; 51 53 Stage.addListener(SampleClient); 54 onResize(); 52 55 53 var buttons :Array = new Array();56 var buttons:Array = new Array(); 54 57 55 buttons.push( makeButton(clip, 'plus', 'zoom in', Delegate.create(__map, __map.zoomIn))); 56 buttons.push( makeButton(clip, 'minus', 'zoom out', Delegate.create(__map, __map.zoomOut))); 57 buttons.push( makeButton(clip, 'clear', 'clear log', Delegate.create(__map.grid, __map.grid.clearLog))); 58 buttons.push(makeButton(clip, 'plus', 'zoom in', Delegate.create(__map, __map.zoomIn))); 59 buttons.push(makeButton(clip, 'minus', 'zoom out', Delegate.create(__map, __map.zoomOut))); 60 buttons.push(makeButton(clip, 'left', 'pan left', Delegate.create(__map, __map.panLeft))); 61 buttons.push(makeButton(clip, 'up', 'pan up', Delegate.create(__map, __map.panUp))); 62 buttons.push(makeButton(clip, 'down', 'pan down', Delegate.create(__map, __map.panDown))); 63 buttons.push(makeButton(clip, 'left', 'pan right', Delegate.create(__map, __map.panRight))); 64 buttons.push(makeButton(clip, 'clear', 'clear log', Delegate.create(__map.grid, __map.grid.clearLog))); 58 65 59 var nextX :Number = __map._x;60 var nextY :Number = __map._y - buttons[0]['label']._height - 10;66 var nextX:Number = __map._x; 67 var nextY:Number = __map._y - buttons[0]['label']._height - 10; 61 68 62 for ( var i : Number = 0; i < buttons.length; i++ ) 63 { 69 for(var i:Number = 0; i < buttons.length; i++) { 64 70 buttons[i]._x = nextX; 65 71 buttons[i]._y = nextY; … … 67 73 } 68 74 69 70 75 // mapProvider buttons 71 76 72 __m pButtons = clip.createEmptyMovieClip( "mpButtons", clip.getNextHighestDepth());77 __mapButtons = clip.createEmptyMovieClip("mpButtons", clip.getNextHighestDepth()); 73 78 74 79 buttons = new Array(); 75 80 76 buttons.push( makeButton(__mpButtons, 'MICROSOFT_ROAD', 'ms road', Delegate.create(SampleClient, SampleClient.switchMapProvider)));77 buttons.push( makeButton(__mpButtons, 'MICROSOFT_AERIAL', 'ms aerial', Delegate.create(SampleClient, SampleClient.switchMapProvider)));78 buttons.push( makeButton(__mpButtons, 'MICROSOFT_HYBRID', 'ms hybrid', Delegate.create(SampleClient, SampleClient.switchMapProvider)));81 buttons.push(makeButton(__mapButtons, 'MICROSOFT_ROAD', 'ms road', Delegate.create(SampleClient, SampleClient.switchMapProvider))); 82 buttons.push(makeButton(__mapButtons, 'MICROSOFT_AERIAL', 'ms aerial', Delegate.create(SampleClient, SampleClient.switchMapProvider))); 83 buttons.push(makeButton(__mapButtons, 'MICROSOFT_HYBRID', 'ms hybrid', Delegate.create(SampleClient, SampleClient.switchMapProvider))); 79 84 80 buttons.push( makeButton(__mpButtons, 'GOOGLE_ROAD', 'google road', Delegate.create(SampleClient, SampleClient.switchMapProvider)));81 buttons.push( makeButton(__mpButtons, 'GOOGLE_AERIAL', 'google aerial', Delegate.create(SampleClient, SampleClient.switchMapProvider)));82 buttons.push( makeButton(__mpButtons, 'GOOGLE_HYBRID', 'google hybrid', Delegate.create(SampleClient, SampleClient.switchMapProvider)));85 buttons.push(makeButton(__mapButtons, 'GOOGLE_ROAD', 'google road', Delegate.create(SampleClient, SampleClient.switchMapProvider))); 86 buttons.push(makeButton(__mapButtons, 'GOOGLE_AERIAL', 'google aerial', Delegate.create(SampleClient, SampleClient.switchMapProvider))); 87 buttons.push(makeButton(__mapButtons, 'GOOGLE_HYBRID', 'google hybrid', Delegate.create(SampleClient, SampleClient.switchMapProvider))); 83 88 84 buttons.push( makeButton(__mpButtons, 'YAHOO_ROAD', 'yahoo road', Delegate.create(SampleClient, SampleClient.switchMapProvider)));85 buttons.push( makeButton(__mpButtons, 'YAHOO_AERIAL', 'yahoo aerial', Delegate.create(SampleClient, SampleClient.switchMapProvider)));86 buttons.push( makeButton(__mpButtons, 'YAHOO_HYBRID', 'yahoo hybrid', Delegate.create(SampleClient, SampleClient.switchMapProvider)));89 buttons.push(makeButton(__mapButtons, 'YAHOO_ROAD', 'yahoo road', Delegate.create(SampleClient, SampleClient.switchMapProvider))); 90 buttons.push(makeButton(__mapButtons, 'YAHOO_AERIAL', 'yahoo aerial', Delegate.create(SampleClient, SampleClient.switchMapProvider))); 91 buttons.push(makeButton(__mapButtons, 'YAHOO_HYBRID', 'yahoo hybrid', Delegate.create(SampleClient, SampleClient.switchMapProvider))); 87 92 88 buttons.push( makeButton(__mpButtons, 'BLUE_MARBLE', 'blue marble', Delegate.create(SampleClient, SampleClient.switchMapProvider)));89 buttons.push( makeButton(__mpButtons, 'OPEN_STREET_MAP', 'open street map', Delegate.create(SampleClient, SampleClient.switchMapProvider)));93 buttons.push(makeButton(__mapButtons, 'BLUE_MARBLE', 'blue marble', Delegate.create(SampleClient, SampleClient.switchMapProvider))); 94 buttons.push(makeButton(__mapButtons, 'OPEN_STREET_MAP', 'open street map', Delegate.create(SampleClient, SampleClient.switchMapProvider))); 90 95 91 __mpButtons._x = 128 + __map._x + __map._width;92 __mpButtons._y = __map._y + 10;93 94 96 nextY = 0; 95 97 96 for ( var i : Number = 0; i < buttons.length; i++ ) 97 { 98 for(var i:Number = 0; i < buttons.length; i++) { 98 99 buttons[i]._y = nextY; 99 100 nextY += buttons[i]['label']._height + 5; 100 101 buttons[i]._alpha = 60; 101 102 } 102 103 103 104 Reactor.callNextFrame(Delegate.create(__map, __map.nagAboutBoundsForever));105 106 104 _root.createEmptyMovieClip('marks', _root.getNextHighestDepth()); 107 105 } 108 106 109 107 110 private static function switchMapProvider( button : MovieClip ) :Void108 private static function switchMapProvider(button:MovieClip):Void 111 109 { 112 110 __map.setMapProvider(MapProviderFactory.getInstance().getMapProvider(MapProviders[button._name])); 113 111 } 114 115 112 116 113 public static function makeButton(clip:MovieClip, name:String, label:String, action:Function):MovieClip … … 135 132 button.onRelease = function() 136 133 { 137 action.apply( SampleClient, [button]);134 action.apply(SampleClient, [button]); 138 135 }; 139 136 … … 141 138 } 142 139 143 public static function output( str : String ) :Void140 public static function output(str:String):Void 144 141 { 145 trace( str);142 trace(str); 146 143 } 147 144 148 145 // Event Handlers 149 146 150 private static function onResize() :Void147 private static function onResize():Void 151 148 { 149 __map._x = __map._y = 50; 152 150 __map.setSize(Stage.width - 2*__map._x, Stage.height - 2*__map._y); 153 __mpButtons._x = __map._x + (Stage.width - 2*__map._x) - __mpButtons._width - 10; 151 152 __mapButtons._x = __map._x + (Stage.width - 2*__map._x) - __mapButtons._width - 10; 153 __mapButtons._y = __map._y + 10; 154 155 __status._width = __map.getSize()[0]; 156 __status._x = __map._x + 2; 157 __status._y = __map._y + __map.getSize()[1]; 154 158 } 159 160 private static function onPanned(event:Object):Void 161 { 162 __status.text = 'Panned by '+event.delta.toString()+', top left: '+__map.getExtent()[0].toString()+', bottom right: '+__map.getExtent()[3].toString(); 163 } 164 165 private static function onStopPan(event:Object):Void 166 { 167 __status.text = 'Stopped panning, top left: '+__map.getExtent()[0].toString()+', center: '+__map.getCenterZoom()[0].toString()+', bottom right: '+__map.getExtent()[3].toString()+', zoom: '+__map.getCenterZoom()[1]; 168 } 169 170 private static function onZoomed(event:Object):Void 171 { 172 __status.text = 'Zoomed by '+event.delta.toString()+', top left: '+__map.getExtent()[0].toString()+', bottom right: '+__map.getExtent()[3].toString(); 173 } 174 175 private static function onStopZoom(event:Object):Void 176 { 177 __status.text = 'Stopped zooming, top left: '+__map.getExtent()[0].toString()+', center: '+__map.getCenterZoom()[0].toString()+', bottom right: '+__map.getExtent()[3].toString()+', zoom: '+__map.getCenterZoom()[1]; 178 } 179 180 private static function onResized(event:Object):Void 181 { 182 __status.text = 'Resized to: '+event.width+' x '+event.height; 183 } 155 184 156 185 private static function onMarkerEnters(event:Object):Void 157 186 { 158 __map.grid.log('+ '+event. markerID.toString()+' =)');187 __map.grid.log('+ '+event.id+' =)'); 159 188 } 160 189 161 190 private static function onMarkerLeaves(event:Object):Void 162 191 { 163 __map.grid.log('- '+event. markerID.toString()+' =(');192 __map.grid.log('- '+event.id+' =('); 164 193 } 165 194 } trunk/as2/lib/SampleFlashLiteClient.as
r137 r160 1 1 import mx.utils.Delegate; 2 2 import com.stamen.twisted.Reactor; 3 import com.modestmaps. geo.Map;3 import com.modestmaps.Map; 4 4 import com.modestmaps.geo.Location; 5 5 import com.modestmaps.mapproviders.MapProviders; … … 17 17 18 18 __map = Map(clip.attachMovie(Map.symbolName, 'map', clip.getNextHighestDepth(), 19 {mapProvider: MapProviderFactory.getInstance().getMapProvider(MapProviders.MICROSOFT_AERIAL), 20 _x: 0, _y: 0, width: Stage.width, height: Stage.height, 21 draggable: true})); 19 {_x: 0, _y: 0})); 22 20 21 __map.init(Stage.width, Stage.height, true, MapProviderFactory.getInstance().getMapProvider(MapProviders.MICROSOFT_AERIAL)); 23 22 24 23 var extent:/*Location*/Array = [new Location(37.829853, -122.514725), 25 24 new Location(37.700121, -122.212601)]; 26 25 27 __map.set InitialExtent(extent);26 __map.setExtent(extent); 28 27 29 28 // Set up key listeners. … … 38 37 { 39 38 case Key.RIGHT: 40 map.pan East( Stage.width);39 map.panRight(); 41 40 break; 42 41 43 42 case Key.LEFT: 44 map.pan West( Stage.width);43 map.panLeft(); 45 44 break; 46 45 47 46 case Key.UP: 48 map.pan North( Stage.height);47 map.panUp(); 49 48 break; 50 49 51 50 case Key.DOWN: 52 map.pan South( Stage.height);51 map.panDown(); 53 52 break; 54 53 }
