zoukankan      html  css  js  c++  java
  • arcgis android 图上记录gps轨迹

    原文  arcgis android 图上记录gps轨迹

    public class MainActivity extends Activity {
    
        MapView mMapView;
        LocationDisplayManager lDisplayManager = null;
        GraphicsLayer gpsGraphicsLayer;
        Polyline mPolyline;
        int pointCount = 0;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            // after the content of this activity is set
            // the map can be accessed from the layout
            mMapView = (MapView) findViewById(R.id.map);
            ArcGISTiledMapServiceLayer tile = new ArcGISTiledMapServiceLayer("http://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity_Mobile/MapServer");
            mMapView.addLayer(tile);
            gpsGraphicsLayer = new GraphicsLayer();
            mMapView.addLayer(gpsGraphicsLayer);
            mPolyline = new Polyline();
            mMapView.setOnStatusChangedListener(new OnStatusChangedListener() {
                @Override
                public void onStatusChanged(Object source, STATUS status) {
                    if (source == mMapView && status == STATUS.INITIALIZED) {
                        lDisplayManager = mMapView.getLocationDisplayManager();//获取LocationDisplayManager
                        lDisplayManager.setAutoPanMode(LocationDisplayManager.AutoPanMode.OFF);
                        lDisplayManager.setShowLocation(false);//不显示当前位置,坐标系不一致坐标偏移严重
                        lDisplayManager.setShowPings(false);
                        lDisplayManager.setAccuracyCircleOn(false);
                        lDisplayManager.setAllowNetworkLocation(true);
                        lDisplayManager.setLocationListener(new LocationListener() {
                            @Override
                            public void onLocationChanged(Location loc) {
                                //火星坐标转换
                                double[] gcj = CoordinateConvert.wgs2GCJ(loc.getLatitude(), loc.getLongitude());
    
                                Point wgspoint = new Point(gcj[1], gcj[0]);
                                Point p = (Point) GeometryEngine.project(wgspoint,
                                        SpatialReference.create(SpatialReference.WKID_WGS84),
                                        mMapView.getSpatialReference());
                                SimpleMarkerSymbol ptSym = new SimpleMarkerSymbol(Color.BLUE, 15,
                                        SimpleMarkerSymbol.STYLE.CIRCLE);
                                Graphic graphic = new Graphic(p, ptSym, null);
                                if (pointCount == 0) {
                                    mPolyline.startPath(p.getX(), p.getY());
                                    mMapView.zoomTo(p, 17);
                                } else {
                                    mPolyline.lineTo(p.getX(), p.getY());//点画线
                                    mMapView.centerAt(p, true);
                                }
                                gpsGraphicsLayer.removeAll();
                                SimpleLineSymbol lineSym = new SimpleLineSymbol(Color.RED, 10);
                                Graphic g = new Graphic(mPolyline, lineSym);
                                gpsGraphicsLayer.addGraphic(g);
                                pointCount++;
    
                                gpsGraphicsLayer.addGraphic(graphic);
                            }
    
                            @Override
                            public void onProviderDisabled(String arg0) {
                            }
    
                            @Override
                            public void onProviderEnabled(String arg0) {
                            }
    
                            @Override
                            public void onStatusChanged(String arg0, int arg1,
                                                        Bundle arg2) {
    
                            }
                        });  // Actionlistener
    
                        lDisplayManager.start();
                    }
                }
            });
    
    
        }
    
    }
  • 相关阅读:
    【BZOJ1067】【SCOI2007】降雨量(线段树)
    【BZOJ3489】A simple rmq problem(树套树)
    【BZOJ1146】【CTSC2008】网络管理
    【BZOJ3236】【Ahoi2013】作业
    计算几何的一些板
    【BZOJ3173】【Tjoi2013】最长上升子序列(树状数组)
    解决phpmyadmin导入长脚本超时
    make报错make: *** [sapi/cli/php] Error 1
    wampserver配置redis在phpinfo()里面找不到
    阿里云服务器安装Apache环境外网不能访问
  • 原文地址:https://www.cnblogs.com/arxive/p/6243776.html
Copyright © 2011-2022 走看看