Convert code from Google Map Android API v1 to Google Map Android API v2? -


this code google map android api v1. don't know convert api v2. me, please!

flatback.java

public class flatback extends mapactivity { private mapview mapview; private mylocationoverlay mylocationoverlay;   @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      setcontentview(r.layout.map);      mapview = (mapview) findviewbyid(r.id.mapview);     mapview.setbuiltinzoomcontrols(true);      mylocationoverlay = new fixlocation(this, mapview);      mapview.getoverlays().add(mylocationoverlay);     mapview.postinvalidate();      zoomtomylocation(); }  @override public boolean oncreateoptionsmenu(menu menu) {     menuinflater inflater = getmenuinflater();     inflater.inflate(r.menu.map_toggle, menu);     return true; }  public boolean onoptionsitemselected(menuitem item) {     switch (item.getitemid()) {     case r.id.map:         if (mapview.issatellite() == true) {             mapview.setsatellite(false);             mapview.setstreetview(true);         }         return true;     case r.id.sat:         if (mapview.issatellite() == false) {             mapview.setsatellite(true);             mapview.setstreetview(false);         }         return true;     case r.id.both:         mapview.setsatellite(true);         mapview.setstreetview(true);     default:         return super.onoptionsitemselected(item);     } }  @override protected void onresume() {     super.onresume();     mylocationoverlay.enablemylocation(); }  @override protected void onpause() {     super.onpause();     mylocationoverlay.disablemylocation(); }  private void zoomtomylocation() {     geopoint mylocationgeopoint = mylocationoverlay.getmylocation();     if (mylocationgeopoint != null) {         mapview.getcontroller().animateto(mylocationgeopoint);         mapview.getcontroller().setzoom(10);     } }  protected boolean isroutedisplayed() {     return false; } 

finally, important add google play services android library project follows:

  • select file > import > android > existing android code workspace , click next. select browse..., enter */extras/google/google_play_services/libproject/google-play-services_lib*, , click finish.
  • check if libs/ folder containing android-support-v4.jar exists in project.
  • android-support-v4.jar located in /extras/android/compatibility/v4/android-support-v4.jar under "android-sdk" drectory.

before running project, must set project build target "google apis", not android x.x. version : select project , click project > properties > project build target in eclipse , select "google apis ", , run project on phone. if use emulator, must set avd of emulator "google apis ".


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -