plz Suggest me any one
i wrote all code for mapview but it does not appeair on emulator it
shows only blocks on emulator
my code is below pls check is there any correction plz tell me .there
is no any error in this code plz suggest me.....
thank you
public class mapDemo extends MapActivity {
MyLocationOverlay mlo;
MapController mpc;
MapView mv;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mv=(MapView)findViewById(R.id.mapview);
final LocationManager
lm=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
final LocationListener ll=new MyLocationListener();
mpc=mv.getController();
mpc.setZoom(18);
mlo=new MyLocationOverlay(this,mv);
mv.getOverlays().add(mlo);
mv.postInvalidate();
final Location
location=lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
updateWithNewLocation(location);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,ll);
mlo.enableMyLocation();
}
private void updateWithNewLocation(Location location) {
// TODO Auto-generated method stub
if (location !=null)
{
final double lat=location.getLatitude();
final double lng=location.getLongitude();
final GeoPoint mylcation=new
GeoPoint((int)(lat*1000000),(int)
(lng*1000000));
mv.getController().animateTo(mylcation);
mv.getController().setCenter(mylcation);
}
}
public class MyLocationListener implements LocationListener{
public void onLocationChanged(final Location location) {
// TODO Auto-generated method stub
updateWithNewLocation(location);
}
public void onProviderDisabled(final String provider) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(),"Gps
Disabled",Toast.LENGTH_LONG).show();
}
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(),"Gps
enabled",Toast.LENGTH_LONG).show();
}
public void onStatusChanged(final String provider,final int
status,final Bundle extras) {
// TODO Auto-generated method stub
}
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
This is my main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.google.android.maps.MapView
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="0n-H5VH-
CoBfLf6SnbeZ6uSICn5gF9rA_5eyXrw"
/>
<LinearLayout
android:id="@+id/zlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
></LinearLayout>
</RelativeLayout>
This is my manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ashwath.mapDemo"
android:versionCode="1"
android:versionName="1.0">
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"></uses-
permission>
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-
permission>
<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=".mapDemo"
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>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en