Changeset 346
- Timestamp:
- 08/15/07 23:05:24 (1 year ago)
- Files:
-
- trunk/as3/lib/com/modestmaps/core/MarkerClip.as (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/as3/lib/com/modestmaps/core/MarkerClip.as
r340 r346 17 17 import flash.display.DisplayObject; 18 18 import flash.utils.getTimer; 19 import flash.geom.Rectangle; 19 20 20 21 /** This is different from the as2 version for now, because … … 56 57 public function attachMarker(marker:DisplayObject, location:Location):void 57 58 { 58 map.grid.putMarker(marker.name, map.getMapProvider().locationCoordinate(location), location);59 //map.grid.putMarker(marker.name, map.getMapProvider().locationCoordinate(location), location); 59 60 60 61 locations[marker] = location; … … 63 64 64 65 var point:Point = map.locationPoint(location, this); 65 marker.x = point.x; 66 marker.y = point.y; 67 68 // TODO: check if it should be added now? 69 addChild(marker); 66 marker.x = Math.round(point.x); 67 marker.y = Math.round(point.y); 68 69 var w:Number = map.getWidth() * 2; 70 var h:Number = map.getHeight() * 2; 71 if (marker.x > -w/2 && marker.x < w/2 && marker.y > -h/2 && marker.y < h/2) { 72 addChild(marker); 73 } 70 74 } 71 75 … … 77 81 public function removeMarker(id:String):void 78 82 { 79 map.grid.removeMarker(id);83 //map.grid.removeMarker(id); 80 84 var marker:DisplayObject = getMarker(id); 81 85 if (marker) { … … 93 97 { 94 98 //var t:int = flash.utils.getTimer(); 99 var w:Number = map.getWidth() * 2; 100 var h:Number = map.getHeight() * 2; 95 101 for each (var marker:DisplayObject in markers) { 96 updateClip(marker); 102 if (marker.visible) { 103 updateClip(marker); 104 if (marker.x > -w/2 && marker.x < w/2 && marker.y > -h/2 && marker.y < h/2) { 105 if (!contains(marker)) { 106 addChild(marker); 107 } 108 } 109 else if (contains(marker)) { 110 removeChild(marker); 111 } 112 } 97 113 } 98 114 //trace("reprojected all markers in " + (flash.utils.getTimer() - t) + "ms"); 99 115 } 100 116 101 p rivatefunction updateClip(marker:DisplayObject):void117 public function updateClip(marker:DisplayObject):void 102 118 { 103 119 var location:Location = locations[marker]; … … 140 156 public function onMapPanned(event:MapEvent):void 141 157 { 142 x = starting.x + event.panDelta.x; 143 y = starting.y + event.panDelta.y; 158 if (starting) { 159 x = starting.x + event.panDelta.x; 160 y = starting.y + event.panDelta.y; 161 } 162 else { 163 x = event.panDelta.x; 164 y = event.panDelta.y; 165 } 144 166 } 145 167
