Android nutiteq地图上的多段线OnLocation已更改

Android nutiteq地图上的多段线OnLocation已更改,android,maps,nutiteq,Android,Maps,Nutiteq,我一直在研究nutiteq地图,但由于位置的变化,我无法绘制多段线 到目前为止,我试过: @Override public void onLocationChanged(Location location) { MapPos lineLocation = mapView.getLayers().getBaseProjection().fromWgs84(location.getLongitude(), location.getLatitude()); //arr_lat_long

我一直在研究nutiteq地图,但由于位置的变化,我无法绘制多段线

到目前为止,我试过:

@Override
public void onLocationChanged(Location location)
{
    MapPos lineLocation = mapView.getLayers().getBaseProjection().fromWgs84(location.getLongitude(), location.getLatitude());
    //arr_lat_long.add(new MapPos(lat, lng));
    arr_lat_long.add(lineLocation);
    Toast.makeText(getApplicationContext(), "Array list lat Lng" + arr_lat_long, 1000).show();
    if (arr_lat_long.size() > 2)
    {
        GeometryLayer geoLayer = new GeometryLayer(new EPSG4326());
        mapView.getLayers().addLayer(geoLayer);
        LineStyle lineStyle = LineStyle.builder().setLineJoinMode(LineStyle.ROUND_LINEJOIN).build();
        //Label label = new DefaultLabel("Line", "Here is a line");
        Line line = new Line(arr_lat_long, null, lineStyle, null);
        geoLayer.add(line);
    }
}

问题是图层投影是EPSG4326,但添加的线位置坐标将转换为基本投影(基本图层投影),通常为EPSG3857。由于您的地质层已经是EPSG4326,GPS坐标也是EPSG4326(WGS84),那么这就足够了:

MapPos lineLocation = new MapPos(location.getLongitude(), location.getLatitude());
另外:在这里,您将为每个GPS位置坐标添加新图层、定义样式并添加新线(每增加一个1点),这将每秒发生一次。所以你迟早会忘记的。所以我建议重写代码:生成geoLayer、lineStyle和line-to字段。并在应用程序/mapview的整个生命周期内使用以下命令更新同一行对象:

line.setVertexList(arr_lat_long);

下面的代码适合我

 @Override
            public void onLocationChanged(Location location)
            {
                Log.debug("GPS onLocationChanged " + location);
                if (locationCircle != null)
                {
                    MapPos lineLocation = mapView.getLayers().getBaseProjection().fromWgs84(location.getLongitude(), location.getLatitude());

                    //arr_lat_long.add(proj.fromWgs84(location.getLongitude(), location.getLatitude()));
                    //arr_lat_long.add(new MapPos(lat, lng));
                    arr_lat_long.add(lineLocation);


                    if (arr_lat_long.size() > 1)
                    {
                        Toast.makeText(getApplicationContext(), "Array list lat Lng" + arr_lat_long, 1000).show();

                        GeometryLayer geoLayer = new GeometryLayer(mapView.getComponents().layers.getBaseProjection());

                        mapView.getLayers().addLayer(geoLayer);
                        //LineStyle lineStyle = LineStyle.builder().setLineJoinMode(LineStyle.ROUND_LINEJOIN).build();  
                        StyleSet<LineStyle> lineStyleSet = new StyleSet<LineStyle>(LineStyle.builder().setWidth(0.05f).setColor(Color.BLUE).build());
                        Line line = new Line(arr_lat_long, null, lineStyleSet, null);
                        geoLayer.add(line);
                    }

                    }
@覆盖
已更改位置上的公共无效(位置)
{
Log.debug(“GPS onLocationChanged”+位置);
如果(locationCircle!=null)
{
MapPos lineLocation=mapView.getLayers().getBaseProjection().fromWgs84(location.GetLength(),location.getLatitude());
//arr_lat_long.add(项目来自WGS84(location.getLength(),location.getLatitude());
//arr_lat_long.添加(新地图位置(lat,lng));
arr_lat_long.add(线路位置);
如果(arr_lat_long.size()>1)
{
makeText(getApplicationContext(),“数组列表lat Lng”+arr_lat_long,1000).show();
GeometryLayer geoLayer=新的GeometryLayer(mapView.getComponents().layers.getBaseProjection());
mapView.getLayers().addLayer(geoLayer);
//LineStyle LineStyle=LineStyle.builder().setLineJoinMode(LineStyle.ROUND_LINEJOIN).build();
StyleSet lineStyleSet=新样式集(LineStyle.builder().setWidth(0.05f).setColor(Color.BLUE).build());
Line Line=新行(arr_lat_long,null,lineStyleSet,null);
添加(行);
}
}

使用nutiteq地图是一种习惯,为什么你不能使用谷歌地图?“接受答案”对你来说很好。接受。你能告诉我在没有网络连接的情况下如何显示多段线吗。我是说在脱机模式下。有没有办法。这张GPS线图也可以脱机使用。至少我看不出有什么理由不这样做。