MAP INTEGRATION IN ANDROID
Step 1:-
package m.l;
import com.google.android.maps.MapView;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import android.os.Bundle;
public class MaplocationActivity extends MapActivity {
/** Called when the activity is first created. */
MapView mv;
MapController mc;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mv = (MapView) findViewById(R.id.mapView);
mv.setTraffic(true);
mv.setBuiltInZoomControls(true);
mc = mv.getController();
mc.setZoom(6);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
import com.google.android.maps.MapView;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import android.os.Bundle;
public class MaplocationActivity extends MapActivity {
/** Called when the activity is first created. */
MapView mv;
MapController mc;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mv = (MapView) findViewById(R.id.mapView);
mv.setTraffic(true);
mv.setBuiltInZoomControls(true);
mc = mv.getController();
mc.setZoom(6);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Step 2:-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.android.maps.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:enabled="true"
android:clickable="true"
android:apiKey="0FVuJdedqG3ZiifLPJ3EoevkIAYeuKPO3JBKPHQ"
/>
</LinearLayout>
Step3:-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="m.l"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
-->
<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-library android:name="com.google.android.maps" />
<activity android:name=".MaplocationActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
-->
No comments :
Post a Comment