Skip to content

Commit

Permalink
permit GPS tracks to be cleared from the usual menu. Fixes #3492
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.openstreetmap.org/applications/editors/potlatch2@25544 b9d5c4c9-76e1-0310-9c85-f3177eceb1e4
  • Loading branch information
richard committed Mar 8, 2011
1 parent 530aa0a commit 7028063
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
14 changes: 14 additions & 0 deletions net/systemeD/halcyon/Map.as
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,20 @@ package net.systemeD.halcyon {
vectorlayers[layer.name]=layer;
vectorbg.addChild(layer.paint);
}

public function removeVectorLayer(layer:VectorLayer):void {
if (!layer) return;
layer.blank();
vectorbg.removeChild(layer.paint);
delete vectorlayers[layer.name];
}

public function findVectorLayer(name:String):VectorLayer {
for each (var layer:VectorLayer in vectorlayers) {
if (layer.name==name) { return layer; }
}
return null;
}

// ------------------------------------------------------------------------------------------
// Redraw all items, zoom in and out
Expand Down
4 changes: 1 addition & 3 deletions net/systemeD/potlatch2/VectorSourceDialog.mxml
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@
}
private function removeVectorLayer():void {
var a:String=dataGrid.selectedItem.name;
map.vectorlayers[a].blank();
delete map.vectorlayers[a];
map.removeVectorLayer(map.vectorlayers[dataGrid.selectedItem.name]);
dispatchEvent(new Event("layers_changed"));
}
Expand Down
12 changes: 5 additions & 7 deletions net/systemeD/potlatch2/utils/TrackLoader.as
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package net.systemeD.potlatch2.utils {
private var top:Number=0;
private var bottom:Number=0;
private var page:uint=0;
private var _layer:VectorLayer;

private var map:Map;
private var apiBaseURL:String;
Expand Down Expand Up @@ -75,14 +74,13 @@ package net.systemeD.potlatch2.utils {
layer.paint.updateEntityUIs(layer.getObjectsByBbox(left,right,top,bottom), false, false);
}


private function get layer():VectorLayer {
if (!_layer) {
var n:String='GPS tracks';
_layer=new VectorLayer(n,map,STYLESHEET);
map.addVectorLayer(_layer);
var vl:VectorLayer=map.findVectorLayer('GPS tracks');
if (!vl) {
vl=new VectorLayer('GPS tracks',map,STYLESHEET);
map.addVectorLayer(vl);
}
return _layer;
return vl;
}

private function greatCircle(lat1:Number,lon1:Number,lat2:Number,lon2:Number):Number {
Expand Down
7 changes: 6 additions & 1 deletion potlatch2.mxml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@
<mx:PopUpButton id="styleButton" label="Map Style" openAlways="true" styleName="appBarButton"
creationComplete="styleButton.popUp = new StyleSelector();"/>
<mx:PopUpMenuButton id="gpsButton" styleName="appBarButton"
itemClick="if (event.index==0) { trackLoader.load(); } else { new MyGpxDialog().init(); }">
itemClick="if (event.index==0) { trackLoader.load(); }
else if (event.index==1) { new MyGpxDialog().init(); }
else { mx.controls.Menu(gpsButton.popUp).selectedIndex=0;
mx.controls.Menu(gpsButton.popUp).selectedIndex=0; /* Yes, we do need to call it twice */
theMap.removeVectorLayer(theMap.findVectorLayer('GPS tracks')); }">
<mx:dataProvider>
<mx:Array>
<mx:Object label="GPS data" id="gpsData" />
<mx:Object label="My tracks" id="myTracks" />
<mx:Object label="Clear" id="gpsClear" />
</mx:Array>
</mx:dataProvider>
</mx:PopUpMenuButton>
Expand Down

0 comments on commit 7028063

Please sign in to comment.