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();
                    }
                }
            });
    
    
        }
    
    }
  • 相关阅读:
    MFC程序执行过程剖析
    不同位数操作系统的 数据长度
    测试:safenet提供的CheckKey函数 内存泄漏。具体来说是句柄.
    关于更改项目名称
    内存泄漏相关的
    美化MFC 之调整静态文本的颜色 字体。 用于添加公司标题 联系方式 口号等数据
    DAVINCI DM365-DM368开发攻略——开发环境搭建(DVSDK4.02)
    Removing Unnecessary HTTP Headers in IIS and ASP.NET 在ASP.Net和IIS中删除不必要的HTTP响应头
    Implementing Singleton in C#
    WEBAPI VS WCF微软随.NET 4.5发布新REST API框架
  • 原文地址:https://www.cnblogs.com/arxive/p/6243776.html
Copyright © 2011-2022 走看看