Maps: Properly handle invisible map items and impossible lines

Fixes #49
This commit is contained in:
mar-v-in 2015-10-29 12:04:37 +01:00
parent 9870ba795f
commit c618221a38
2 changed files with 9 additions and 1 deletions

View File

@ -38,6 +38,7 @@ import org.oscim.layers.marker.MarkerSymbol;
import org.oscim.layers.tile.buildings.BuildingLayer;
import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.layers.tile.vector.labeling.LabelLayer;
import org.oscim.layers.vector.geometries.Drawable;
import org.oscim.map.Layers;
import org.oscim.map.Map;
import org.oscim.map.Viewport;
@ -171,7 +172,10 @@ public class BackendMap implements ItemizedLayer.OnItemGestureListener<MarkerIte
private synchronized void updateDrawableLayer() {
drawables.clear();
for (DrawableMarkup markup : drawableMarkups) {
drawables.add(markup.getDrawable(mapView.map()));
Drawable drawable = markup.getDrawable(mapView.map());
if (drawable != null) {
drawables.add(drawable);
}
}
}

View File

@ -148,6 +148,10 @@ public class PolylineImpl extends IPolylineDelegate.Stub implements DrawableMark
@Override
public Drawable getDrawable(Map map) {
if (!isVisible() || removed) return null;
if (options.getPoints().size() < 2) {
// You hardly draw a line with less than two points
return null;
}
List<GeoPoint> points = new ArrayList<GeoPoint>();
for (LatLng point : options.getPoints()) {
points.add(GmsMapsTypeHelper.fromLatLng(point));