【问题标题】:avoid reload arcgis map on android避免在 android 上重新加载 arcgis 地图
【发布时间】:2019-07-09 02:45:20
【问题描述】:

我经常移动一个点,问题是为了将点保持在地图内并且在移动时不会丢失,我必须重新加载地图。你怎么能避免给它充电,因为每两秒移动一次,每两秒重新加载一次地图太不舒服了。

代码如下:

  cont++;
        final long EXECUTION_TIME = 2000;
        final Handler handler = new Handler();

       handler.postDelayed(new Runnable() {
            int aux = 0;               
            @Override
            public void run() {

                        GraphicsOverlay graphicsOverlay1 = new GraphicsOverlay();
                        Graphic g1 = new Graphic(getLatLong(aux), attributes, sms);
                        graphicsOverlay1.getGraphics().add(g1);

                        mMap.getGraphicsOverlays().add(graphicsOverlay1);
                        map = new ArcGISMap(basemapType, getLatLong(aux).getY(), getLatLong(aux).getX(), 17);

                        mMap.setMap(map);  //Here is where the map is reloaded, some other way to avoid this burden


                        handler.postDelayed(this, EXECUTION_TIME);
    }
)};

【问题讨论】:

    标签: android-studio arcgis arcgis-android-api


    【解决方案1】:

    您必须在您的mMap 中使用SetViewpointCenterAsync 方法,从而避免在更新地图上的点时加载地图。

    代码如下所示:

    map = new ArcGISMap(basemapType, getLatLong(aux).getY(), getLatLong(aux).getX(), 17);
    
    mMap.setMap(map); 
    cont++;
    final long EXECUTION_TIME = 2000;
    final Handler handler = new Handler();
    
      handler.postDelayed(new Runnable() {
    int aux = 0;               
    @Override
    public void run() {
    
                GraphicsOverlay graphicsOverlay1 = new GraphicsOverlay();
                Graphic g1 = new Graphic(getLatLong(aux), attributes, sms);
                graphicsOverlay1.getGraphics().add(g1);
    
                mMap.getGraphicsOverlays().add(graphicsOverlay1);
    
                mMap.setViewpointCenterAsync(new Point( getLatLong(aux).getX(), getLatLong(aux).getY(),SpatialReferences.getWgs84()),6000.0) ;
                handler.postDelayed(this, EXECUTION_TIME);   }   )};
    

    【讨论】:

      猜你喜欢
      • 2012-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-08
      • 2018-04-12
      • 2013-03-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多