将经纬度转换为 esri arcGIS MapPoint

Convert latitude and longitude into esri arcGIS MapPoint(将经纬度转换为 esri arcGIS MapPoint)
本文介绍了将经纬度转换为 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)