将经纬度转换为 esri arcGIS MapPoint经纬度、转换为、esri、arcGIS

2023-09-07 04:41:41 作者:本人已死

我在将纬度和经度值转换为 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();

     }
   }
});