fix: 增加多线图层
This commit is contained in:
parent
61ba1d1d2f
commit
58136320d4
@ -41,6 +41,7 @@ import org.oscim.layers.tile.buildings.BuildingLayer
|
|||||||
import org.oscim.layers.tile.vector.VectorTileLayer
|
import org.oscim.layers.tile.vector.VectorTileLayer
|
||||||
import org.oscim.layers.tile.vector.labeling.LabelLayer
|
import org.oscim.layers.tile.vector.labeling.LabelLayer
|
||||||
import org.oscim.layers.tile.vector.labeling.LabelTileLoaderHook
|
import org.oscim.layers.tile.vector.labeling.LabelTileLoaderHook
|
||||||
|
import org.oscim.layers.vector.VectorLayer
|
||||||
import org.oscim.map.Map
|
import org.oscim.map.Map
|
||||||
import org.oscim.map.Map.UpdateListener
|
import org.oscim.map.Map.UpdateListener
|
||||||
import org.oscim.tiling.source.OkHttpEngine.OkHttpFactory
|
import org.oscim.tiling.source.OkHttpEngine.OkHttpFactory
|
||||||
@ -142,6 +143,12 @@ open class LayerManagerHandler(context: AppCompatActivity, mapView: NIMapView,tr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化任务Link高亮的图层
|
||||||
|
* */
|
||||||
|
private fun initOMDBTaskVectorLayer() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 切换基础底图样式
|
* 切换基础底图样式
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,170 @@
|
|||||||
|
package com.navinfo.collect.library.map.layers;
|
||||||
|
|
||||||
|
import com.navinfo.collect.library.utils.GeometryTools;
|
||||||
|
import org.locationtech.jts.geom.Geometry;
|
||||||
|
import org.locationtech.jts.geom.LineString;
|
||||||
|
import org.oscim.core.GeoPoint;
|
||||||
|
import org.oscim.layers.vector.PathLayer;
|
||||||
|
import org.oscim.layers.vector.geometries.LineDrawable;
|
||||||
|
import org.oscim.layers.vector.geometries.PolygonDrawable;
|
||||||
|
import org.oscim.layers.vector.geometries.Style;
|
||||||
|
import org.oscim.map.Map;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by xiaoxiao on 2018/3/26.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class MultiPathLayer extends PathLayer {
|
||||||
|
private List<LineDrawable> pathDrawableList;
|
||||||
|
|
||||||
|
public MultiPathLayer(Map map, Style style) {
|
||||||
|
super(map, style);
|
||||||
|
mStyle = style;
|
||||||
|
pathDrawableList = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MultiPathLayer(Map map, Style style, String name) {
|
||||||
|
this(map, style);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MultiPathLayer(Map map, int lineColor, float lineWidth, int fillColor, float fillAlpha) {
|
||||||
|
this(map, Style.builder()
|
||||||
|
.stippleColor(lineColor)
|
||||||
|
.stipple(24)
|
||||||
|
.stippleWidth(lineWidth)
|
||||||
|
.strokeWidth(lineWidth)
|
||||||
|
.strokeColor(lineColor).fillColor(fillColor).fillAlpha(fillAlpha)
|
||||||
|
.fixed(true)
|
||||||
|
.randomOffset(false)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
public MultiPathLayer(Map map, int lineColor, int fillColor, float fillAlpha) {
|
||||||
|
this(map, lineColor, 0.5f, fillColor, fillAlpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置polygon的点位
|
||||||
|
*/
|
||||||
|
public void setPathList(List<List<GeoPoint>> pointListList) {
|
||||||
|
if (pointListList == null || pointListList.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (List<GeoPoint> pointList : pointListList) {
|
||||||
|
if (pointList == null || pointList.size() < 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
synchronized (this) {
|
||||||
|
LineDrawable lineDrawable = new LineDrawable(pointList, mStyle);
|
||||||
|
add(lineDrawable);
|
||||||
|
pathDrawableList.add(lineDrawable);
|
||||||
|
}
|
||||||
|
mWorker.submit(0);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除正在绘制的polygon的图形
|
||||||
|
*/
|
||||||
|
public void removePathDrawable(int i) {
|
||||||
|
if (pathDrawableList != null && pathDrawableList.size() > i) {
|
||||||
|
remove(pathDrawableList.get(i));
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePathDrawable(List<GeoPoint> geoPointList) {
|
||||||
|
LineString path = GeometryTools.getLineStrinGeo(geoPointList);
|
||||||
|
removePolygonDrawable(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePathDrawable(String pathStr) {
|
||||||
|
LineString path = (LineString) GeometryTools.createGeometry(pathStr);
|
||||||
|
removePolygonDrawable(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePolygonDrawable(Geometry path) {
|
||||||
|
if (pathDrawableList != null && !pathDrawableList.isEmpty()) {
|
||||||
|
Iterator iterator = pathDrawableList.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
LineDrawable lineDrawable = (LineDrawable) iterator.next();
|
||||||
|
if (GeometryTools.createGeometry(lineDrawable.getGeometry().toString()).equals(path)) {
|
||||||
|
remove(lineDrawable);
|
||||||
|
iterator.remove();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mWorker.submit(0);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPathDrawable(List<GeoPoint> pointList) {
|
||||||
|
if (pathDrawableList != null) {
|
||||||
|
if (pointList == null || pointList.size() < 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
synchronized (this) {
|
||||||
|
LineDrawable pathDrawable = new LineDrawable(pointList, mStyle);
|
||||||
|
add(pathDrawable);
|
||||||
|
pathDrawableList.add(pathDrawable);
|
||||||
|
}
|
||||||
|
mWorker.submit(0);
|
||||||
|
}
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPathDrawable(LineString lineString) {
|
||||||
|
List<GeoPoint> geoPointList = GeometryTools.getGeoPoints(lineString.toString());
|
||||||
|
addPathDrawable(geoPointList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<LineString> getAllPathList() {
|
||||||
|
if (pathDrawableList != null && !pathDrawableList.isEmpty()) {
|
||||||
|
List<LineString> pathList = new ArrayList<>();
|
||||||
|
for (LineDrawable pathDrawable : pathDrawableList) {
|
||||||
|
pathList.add((LineString) GeometryTools.createGeometry(pathDrawable.getGeometry().toString()));
|
||||||
|
}
|
||||||
|
return pathList;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<List<GeoPoint>> getAllPathGeoPointList() {
|
||||||
|
List<LineString> pathList = getAllPathList();
|
||||||
|
if (pathList != null) {
|
||||||
|
List<List<GeoPoint>> geopointList = new ArrayList<>();
|
||||||
|
for (LineString path : pathList) {
|
||||||
|
geopointList.add(GeometryTools.getGeoPoints(path.toString()));
|
||||||
|
}
|
||||||
|
return geopointList;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<LineDrawable> getPolygonDrawableList() {
|
||||||
|
return pathDrawableList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPolygonDrawableList(List<LineDrawable> pathDrawableList) {
|
||||||
|
this.pathDrawableList = pathDrawableList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAllPathDrawable(){
|
||||||
|
if (pathDrawableList != null && !pathDrawableList.isEmpty()) {
|
||||||
|
Iterator iterator = pathDrawableList.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
LineDrawable lineDrawable = (LineDrawable) iterator.next();
|
||||||
|
remove(lineDrawable);
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
mWorker.submit(0);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.navinfo.collect.library.map.layers;
|
||||||
|
|
||||||
|
import org.oscim.layers.vector.VectorLayer;
|
||||||
|
import org.oscim.layers.vector.geometries.Drawable;
|
||||||
|
import org.oscim.map.Map;
|
||||||
|
import org.oscim.utils.SpatialIndex;
|
||||||
|
|
||||||
|
public class OmdbTaskLinkLayer extends VectorLayer {
|
||||||
|
public OmdbTaskLinkLayer(Map map, SpatialIndex<Drawable> index) {
|
||||||
|
super(map, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OmdbTaskLinkLayer(Map map) {
|
||||||
|
super(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user