Skip to content

Commit 9575f58

Browse files
committed
Closes #119
1 parent 4f8a8ef commit 9575f58

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
public class OSMMap implements MapViewListener, MapListener {
3636

3737
// DEBUG MODE - SHOW ENVELOPE AROUND TAP ON MAP
38-
private static final boolean DEBUG = true;
38+
private static final boolean DEBUG = false;
3939

4040
private MapView mapView;
4141
private JTSModel jtsModel;

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,11 @@ public OSMElement queryFromTap(ILatLng latLng, float zoom) {
166166

167167
}
168168

169-
// Log.i("queryFromTap closestElement", closestElement.toString());
170-
return closestElement;
169+
Geometry closestElementGeom = closestElement.getJTSGeom();
170+
if (closestElementGeom != null && closestElementGeom.intersects(geometryFactory.createPoint(coord))) {
171+
return closestElement;
172+
}
173+
return null;
171174
}
172175

173176
private Envelope createTapEnvelope(Coordinate coord, double lat, double lng, float zoom) {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,12 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
289289
*/
290290
protected void identifyOSMFeature(OSMElement osmElement) {
291291

292+
// only open it if we render the OSM vectors,
293+
// otherwise it is confusing for the user
294+
if (mapView.getZoomLevel() < OSMMapBuilder.MIN_VECTOR_RENDER_ZOOM) {
295+
return;
296+
}
297+
292298
int numRequiredTags = 0;
293299
if (ODKCollectHandler.isODKCollectMode()) {
294300
Collection<ODKTag> requiredTags = ODKCollectHandler.getODKCollectData().getRequiredTags();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
*/
3636
public class OSMMapBuilder extends AsyncTask<File, Long, JTSModel> {
3737

38-
private static final float MIN_VECTOR_RENDER_ZOOM = 18;
38+
public static final float MIN_VECTOR_RENDER_ZOOM = 18;
3939
private static final String PERSISTED_OSM_FILES = "org.redcross.openmapkit.PERSISTED_OSM_FILES";
4040

4141
private static MapActivity mapActivity;

0 commit comments

Comments
 (0)