RasterMap can be used to translate a map. panTo moves the map to the coordinates of the specified longitude and latitude. panDirection (dx, dy) translates the map into dx and dy pixels from the current position.
GuidebeeMapView implements TouchEvent processing. You can use the Touch event to pan the map. The following example uses the menu to pan the map above, down, left, and right.
[Java]
Package com. pstreets. gisengine. demo;
Import com. mapdigit. gis. geometry. GeoLatLng;
Import com. pstreets. gisengine. R;
Import com. pstreets. gisengine. SharedMapInstance;
Import com. mapdigit. gis. raster. MapType;
Import android. app. Activity;
Import android. OS. Bundle;
Import android. view. Menu;
Import android. view. MenuInflater;
Import android. view. MenuItem;
Public class MapPan extends Activity {
@ Override
Public void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. main );
}
@ Override
Public void onStart (){
Super. onStart ();
GeoLatLng center = new GeoLatLng (32.0616667, 118.7777778 );
SharedMapInstance. map. setCenter (center, 13, MapType. MICROSOFTCHINA );
}
@ Override
Public boolean onCreateOptionsMenu (Menu menu ){
MenuInflater inflater = getMenuInflater ();
Inflater. inflate (R. menu. mappan_menu, menu );
Return true;
}
@ Override
Public boolean onOptionsItemSelected (MenuItem item ){
// Handle item selection
Switch (item. getItemId ()){
Case R. id. mapup:
SharedMapInstance. map. panDirection (0,-32 );
Return true;
Case R. id. mapdown:
SharedMapInstance. map. panDirection (0, 32 );
Return true;
Case R. id. mapleft:
SharedMapInstance. map. panDirection (-32, 0 );
Return true;
Case R. id. mapright:
SharedMapInstance. map. panDirection (32, 0 );
Return true;
Default:
Return super. onOptionsItemSelected (item );
}
}
}
Author: mapdigit