mapquest版OpenStreetMapのMyLocationだけ使ってみる
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <supports-screens android:anyDensity="true"/>
<string name="api_key">Kmjtd%7Cluu22gurnq%2Can%3Do5-gzrl</string>
import android.os.Bundle; import android.app.Activity; import android.view.Menu; ・ ・ ・ import com.mapquest.android.maps.GeoPoint; import com.mapquest.android.maps.MapActivity; import com.mapquest.android.maps.MapView; import com.mapquest.android.maps.MyLocationOverlay; ・ ・ ・ public class MainActivity extends Activity { protected MapView myMap; protected MyLocationOverlay myLocationOverlay; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.followme_map); setupMapView(); setupMyLocation(); } private void setupMapView() { this.myMap = (MapView) findViewById(R.id.map); // enable the zoom controls myMap.setBuiltInZoomControls(true); } protected void setupMyLocation() { this.myLocationOverlay = new MyLocationOverlay(this, myMap); myLocationOverlay.enableMyLocation(); myLocationOverlay.runOnFirstFix(new Runnable() { @Override public void run() { GeoPoint currentLocation = myLocationOverlay.getMyLocation(); myMap.getController().animateTo(currentLocation); myMap.getController().setZoom(14); myMap.getOverlays().add(myLocationOverlay); myLocationOverlay.setFollowing(true); } }); } @Override protected void onStart() { myLocationOverlay.setFollowing(true); super.onStart(); } @Override protected void onResume() { myLocationOverlay.enableMyLocation(); myLocationOverlay.enableCompass(); super.onResume(); } @Override protected void onPause() { super.onPause(); myLocationOverlay.disableCompass(); myLocationOverlay.disableMyLocation(); } }