本文介绍了将经纬度转换为 esri arcGIS MapPoint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将纬度和经度值转换为 android esri arcGIS 地图点时遇到问题.这是我从 GPS 坐标中获取纬度和经度值的代码:

I am having trouble in converting the latitude and longitude values into android esri arcGIS map Point. Here's my code to get latitude and longitude values from GPS coordinates:

LocationManager lm;
String towers;
double lat;
double longi;
TextView txt;

            lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
            Criteria crit = new Criteria();
            towers = lm.getBestProvider(crit, false);
            Location location = lm.getLastKnownLocation(towers);

            if(location != null)
            {
                lat = location.getLatitude();
                longi = location.getLongitude();
            }

现在我有了纬度和经度值.现在我需要的只是将这些值转换为有效的 esri arcGIS MapPoint.谁能帮帮我?

now I have the latitude and longitude values. Now all I need is to convert these values into valid esri arcGIS MapPoint. Can anyone help me?

提前致谢.

推荐答案

是的,有可能.但是你没有在 ArcGis 中使用 locationmanager.

Yes, it is possible. But you don't use the locationmanager in ArcGis.

ArcGIS 有类似LocationListener 的预定义方法,即:OnStatusChangedListener.

ArcGIS has the predefined method like LocationListener, that is: OnStatusChangedListener.

将位置纬度和经度转换为 esri arcGIS MapPoint,请参见以下代码.

See the below code for converting location latitude and longitude into esri arcGIS MapPoint.

     mMapView.setOnStatusChangedListener(new OnStatusChangedListener() {

            /**
             *
             */
      private static final long serialVersionUID = 1L;

      public void onStatusChanged(Object source, STATUS status) {
      if (source == mMapView && status == STATUS.INITIALIZED) {
      LocationService ls = mMapView.getLocationService();
      ls.setAutoPan(false);
      ls.setLocationListener(new LocationListener() {

      boolean locationChanged = false;

      // Zooms to the current location when first GPS fix
      // arrives.
      public void onLocationChanged(Location loc) {
      if (!locationChanged) {
      locationChanged = true;
      double locy = loc.getLatitude();
      double locx = loc.getLongitude();
      Point wgspoint = new Point(locx, locy);
      Point mapPoint = (Point) GeometryEngine.project(wgspoint,

      SpatialReference.create(4326),

      mMapView.getSpatialReference());

      Unit mapUnit = mMapView.getSpatialReference().getUnit();
      double zoomWidth = Unit.convertUnits(

      SEARCH_RADIUS, Unit.create(LinearUnit.Code.MILE_US), mapUnit);
      Envelope zoomExtent = new Envelope(mapPoint, zoomWidth, zoomWidth);

      mMapView.setExtent(zoomExtent);

      GraphicsLayer gLayer = new GraphicsLayer();
      PictureMarkerSymbol symbol = new
      PictureMarkerSymbol(getResources().getDrawable(R.drawable.twiz_car_red));
      Graphic graphic = new Graphic(mapPoint, symbol);
      //Graphic point=new Graphic(new Point(x, y),new
      SimpleMarkerSymbol(Color.CYAN,20,STYLE.CIRCLE));
      gLayer.addGraphic(graphic);
      mMapView .addLayer(gLayer);

         }
      }

      public void onProviderDisabled(String arg0) {

            }
      public void onProviderEnabled(String arg0) {
            }

      public void onStatusChanged(String arg0, int arg1,
      Bundle arg2) {

         }
        });
      ls.start();

     }
   }
});

这篇关于将经纬度转换为 esri arcGIS MapPoint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 04:19