如果已经回答,请提前道歉。我无法在线或在存储库中找到任何指向我的问题的内容。
我有一个ArrayList<Position>
持有我的线路。
使用addPolyline
我想设置线条,所以我切换到使用线条图层。然而。
该线不再出现在靠近正确位置的任何地方。该地点位于英格兰坎布里亚郡,但是被索马里海岸所吸引。
我试图在每次转换后输出坐标,它们都显示正常。我无法弄清楚如何检查source
Log.d("Tracing 1", route.toString())
val lineString = LineString.fromCoordinates(route)
Log.d("Tracing 2", lineString.coordinates.toString())
val feature = Feature.fromGeometry(lineString)
Log.d("Tracing 3", feature.geometry.coordinates.toString())
val featureCollection = FeatureCollection.fromFeatures(
arrayOf(feature))
val geoJsonSource: Source = GeoJsonSource("line-source", featureCollection)
mapboxMap.addSource(geoJsonSource)
val debugSource = mapboxMap.getSource("line-source") as GeoJsonSource
Log.d("Tracing 4", debugSource.toString())
val lineLayer = LineLayer("linelayer", "line-source")
lineLayer.setProperties(
PropertyFactory.lineDasharray(arrayOf(0.01f, 2f)),
PropertyFactory.lineCap(LINE_CAP_ROUND),
PropertyFactory.lineJoin(LINE_JOIN_ROUND),
PropertyFactory.lineWidth(5f),
PropertyFactory.lineColor(Color.parseColor("#e55e5e"))
)
mapboxMap.addLayer(lineLayer)
val cameraPosition = CameraPosition.Builder()
.target(LatLng(route[0].latitude, route[0].longitude))
.build()
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
显示Log
s都相同的log cat输出在这里。
10-05 20:52:37.162 11449-11449/com.xxx.xxx D/Tracing 1: [Position [longitude=54.82269833333333, latitude=-2.8017883333333335, altitude=NaN], Position [longitude=54.82289833333333, latitude=-2.80173, altitude=NaN], Position [longitude=54.823098333333334, latitude=-2.8015583333333334, altitude=NaN], Position [longitude=54.8233, latitude=-2.8012799999999998, altitude=NaN], Position [longitude=54.82339833333334, latitude=-2.801078333333333, altitude=NaN], Position [longitude=54.82379833333333, latitude=-2.8007583333333335, altitude=NaN], Position [longitude=54.8241, latitude=-2.8004183333333335, altitude=NaN]]
10-05 20:52:37.172 11449-11449/com.xxx.xxx D/Tracing 2: [Position [longitude=54.82269833333333, latitude=-2.8017883333333335, altitude=NaN], Position [longitude=54.82289833333333, latitude=-2.80173, altitude=NaN], Position [longitude=54.823098333333334, latitude=-2.8015583333333334, altitude=NaN], Position [longitude=54.8233, latitude=-2.8012799999999998, altitude=NaN], Position [longitude=54.82339833333334, latitude=-2.801078333333333, altitude=NaN], Position [longitude=54.82379833333333, latitude=-2.8007583333333335, altitude=NaN], Position [longitude=54.8241, latitude=-2.8004183333333335, altitude=NaN]]
10-05 20:52:37.172 11449-11449/com.xxx.xxx D/Tracing 3: [Position [longitude=54.82269833333333, latitude=-2.8017883333333335, altitude=NaN], Position [longitude=54.82289833333333, latitude=-2.80173, altitude=NaN], Position [longitude=54.823098333333334, latitude=-2.8015583333333334, altitude=NaN], Position [longitude=54.8233, latitude=-2.8012799999999998, altitude=NaN], Position [longitude=54.82339833333334, latitude=-2.801078333333333, altitude=NaN], Position [longitude=54.82379833333333, latitude=-2.8007583333333335, altitude=NaN], Position [longitude=54.8241, latitude=-2.8004183333333335, altitude=NaN]]
10-05 20:52:37.182 11449-11449/com.xxx.xxx D/Tracing 4: com.mapbox.mapboxsdk.style.sources.GeoJsonSource@9d382a28
我的问题是;我做错了什么是我缺少的东西?
由于
答案 0 :(得分:4)
对于MapBox,您必须以相反的顺序提供纬度和经度。 您的问题是您已经为每个点切换了经度和纬度坐标。