Android guide bee map development example: Map Translation

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.