Skip to content

Commit 226c5a3

Browse files
committed
Closes #98. Some bug in Mapbox SDK forces me into a very wretched hack. Should be good enough fix.
1 parent e6a1e09 commit 226c5a3

4 files changed

Lines changed: 21 additions & 7 deletions

File tree

MapboxAndroidSDK/src/main/java/com/spatialdev/osm/OSMMap.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,27 +206,30 @@ private void updateBoundingBox() {
206206
}
207207
}
208208

209-
public void addNode() {
209+
public OSMNode addNode() {
210210
LatLng center = mapView.getCenter();
211211
OSMNode node = new OSMNode(center);
212212
jtsModel.addOSMStandaloneNode(node);
213213
mapView.invalidate();
214+
return node;
214215
}
215216

216-
public void addNode(OSMNode node) {
217+
public OSMNode addNode(OSMNode node) {
217218
Marker marker = node.getMarker();
218219
if (marker != null) {
219220
marker.setVisibility(true);
220221
}
221222
jtsModel.addOSMStandaloneNode(node);
222223
mapView.invalidate();
224+
return node;
223225
}
224226

225-
public void moveNode() {
227+
public OSMNode moveNode() {
226228
LatLng center = mapView.getCenter();
227229
OSMNode selectedNode = (OSMNode)OSMElement.getSelectedElements().getFirst();
228230
selectedNode.move(jtsModel, center);
229231
mapView.invalidate();
232+
return selectedNode;
230233
}
231234

232235
public OSMNode deleteNode() {

MapboxAndroidSDK/src/main/java/com/spatialdev/osm/model/OSMNode.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import java.io.IOException;
1616
import java.util.LinkedList;
1717
import java.util.List;
18+
import java.util.Timer;
19+
import java.util.TimerTask;
1820

1921
public class OSMNode extends OSMElement {
2022

@@ -152,6 +154,16 @@ public void select() {
152154
super.select();
153155
if (marker != null) {
154156
marker.setMarker(marker.getMapView().getContext().getResources().getDrawable(R.mipmap.maki_star_orange));
157+
} else {
158+
// Very wretched hack. Something is wrong with Mapbox Android SDK (Deprecated). Satisfies #98
159+
new Timer().schedule(new TimerTask() {
160+
@Override
161+
public void run() {
162+
if (marker != null) {
163+
marker.setMarker(marker.getMapView().getContext().getResources().getDrawable(R.mipmap.maki_star_orange));
164+
}
165+
}
166+
}, 100);
155167
}
156168
}
157169

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ Android mobile application for browsing OpenStreetMap features to create and edi
1414
- Can be launched by your XForm survey to select OSM features and create/edit tags within your survey collection workflow.
1515
- Tags and OSM ID are sent back to ODK Collect to be stored in survey data
1616

17-
18-
![OpenMapKit Flowchart](/docs/assets/OpenMapKit_flowchart.png)
19-
2017
## Documentation
2118

2219
See the [wiki](https://github.com/AmericanRedCross/openmapkit/wiki) for details on how to setup and load data into the app.

app/src/main/java/org/redcross/openmapkit/MapActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,10 @@ protected void initializeAddNodeButtons() {
376376
View.OnClickListener listener = new View.OnClickListener() {
377377
@Override
378378
public void onClick(View v) {
379-
osmMap.addNode();
379+
OSMNode node = osmMap.addNode();
380380
toggleNodeMode();
381+
node.select();
382+
identifyOSMFeature(node);
381383
}
382384
};
383385
addNodeMarkerBtn.setOnClickListener(listener);

0 commit comments

Comments
 (0)