fix: 增加任务数据高亮功能
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.navinfo.collect.library.data.entity
|
||||
|
||||
import io.realm.RealmObject
|
||||
|
||||
open class HadLinkDvoBean @JvmOverloads constructor(
|
||||
/**
|
||||
* 图幅号
|
||||
*/
|
||||
var mesh: String = "",
|
||||
/**
|
||||
* linkPid
|
||||
*/
|
||||
var linkPid: String = "",
|
||||
/**
|
||||
* (几何)加偏后
|
||||
*/
|
||||
var geometry: String = ""
|
||||
|
||||
) : RealmObject()
|
||||
@@ -26,7 +26,7 @@ import org.oscim.layers.vector.VectorLayer
|
||||
import org.oscim.layers.vector.geometries.Style
|
||||
import org.oscim.map.Map
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(context, mapView),
|
||||
Map.UpdateListener {
|
||||
|
||||
@@ -60,6 +60,16 @@ class LineHandler(context: AppCompatActivity, mapView: NIMapView) : BaseHandler(
|
||||
private val mDefaultPathLayer: PathLayer
|
||||
|
||||
val omdbTaskLinkLayer by lazy {
|
||||
val omdbTaskLinkLayer = OmdbTaskLinkLayer(mMapView.vtmMap,
|
||||
Style.builder()
|
||||
// .stippleColor(context.resources.getColor(R.color.draw_line_red_color, null))
|
||||
.fillColor(context.resources.getColor(R.color.draw_line_red_color, null))
|
||||
.fillAlpha(0.5f)
|
||||
.strokeColor(context.resources.getColor(R.color.draw_line_red_color, null))
|
||||
.strokeWidth(4f)
|
||||
.fixed(true).build())
|
||||
addLayer(omdbTaskLinkLayer, NIMapView.LAYER_GROUPS.VECTOR)
|
||||
omdbTaskLinkLayer
|
||||
}
|
||||
|
||||
init {
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.navinfo.collect.library.map.layers;
|
||||
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
import org.locationtech.jts.geom.LineString;
|
||||
import org.oscim.layers.vector.VectorLayer;
|
||||
import org.oscim.layers.vector.geometries.Drawable;
|
||||
import org.oscim.layers.vector.geometries.Style;
|
||||
import org.oscim.map.Map;
|
||||
import org.oscim.utils.SpatialIndex;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class OmdbTaskLinkLayer extends VectorLayer {
|
||||
private java.util.Map<String, LineString> lineList = new HashMap<>();
|
||||
private Style style;
|
||||
public OmdbTaskLinkLayer(Map map) {
|
||||
super(map);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.navinfo.collect.library.map.layers
|
||||
|
||||
import android.graphics.Color
|
||||
import com.navinfo.collect.library.R
|
||||
import com.navinfo.collect.library.data.entity.HadLinkDvoBean
|
||||
import com.navinfo.collect.library.utils.GeometryTools
|
||||
import org.locationtech.jts.geom.Geometry
|
||||
import org.oscim.layers.vector.VectorLayer
|
||||
import org.oscim.layers.vector.geometries.Drawable
|
||||
import org.oscim.layers.vector.geometries.LineDrawable
|
||||
import org.oscim.layers.vector.geometries.Style
|
||||
import org.oscim.map.Map
|
||||
|
||||
class OmdbTaskLinkLayer(map: Map, private var style: Style) : VectorLayer(map) {
|
||||
private val lineMap = HashMap<String, Drawable>()
|
||||
|
||||
fun addLine(hadLinkDvoBean: HadLinkDvoBean, style: Style = this.style) {
|
||||
hadLinkDvoBean.let {
|
||||
if (!lineMap.containsKey(it.linkPid)) {
|
||||
// 添加geometry到图层上
|
||||
val lineDrawable = LineDrawable(GeometryTools.createGeometry(it.geometry), style)
|
||||
super.add(lineDrawable)
|
||||
lineMap[it.linkPid] = lineDrawable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun addLineList(hadLinkDvoBeanList: List<HadLinkDvoBean>, style: Style = this.style) {
|
||||
hadLinkDvoBeanList.forEach {
|
||||
addLine(it, style)
|
||||
}
|
||||
}
|
||||
|
||||
fun removeLine(linkPid: String):Boolean {
|
||||
if (lineMap.containsKey(linkPid)) {
|
||||
super.remove(lineMap[linkPid])
|
||||
lineMap.remove(linkPid)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun removeLine(geometry: Geometry) {
|
||||
super.remove(geometry)
|
||||
}
|
||||
|
||||
fun setLineColor(color: Color) {
|
||||
this.style = Style.builder()
|
||||
.fillColor(color.toArgb())
|
||||
.fillAlpha(0.5f)
|
||||
.strokeColor(color.toArgb())
|
||||
.strokeWidth(4f)
|
||||
.fixed(true).build()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user