我经常移动一个点,问题是要将该点保留在地图内而不在移动时迷路,我必须重新加载地图。由于每两秒钟发生一次移动并且每两秒钟重新加载地图,您将如何避免对其充电。
代码在这里:
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);
}
)};
答案 0 :(得分: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); } )};