I cant view maps in my application on my device (HTC Wildfi)

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

I cant view maps in my application on my device (HTC Wildfi)

Postby maulik6758 » Fri Apr 22, 2011 1:51 pm

AndroidManifest.xml
-------------------------

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.javacodegeeks.android.googlemaps"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.INSTALL_LOCATION_PROVIDER"></uses-permission>

<application android:icon="@drawable/icon" android:label="@string/app_name">

<activity android:name=".GMapsActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<uses-library android:name="com.google.android.maps" />

</application>

<uses-permission android:name="android.permission.INTERNET"/>

</manifest>

-------------------------------------------------------------------------------------------------------------------------------------

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
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:enabled="true"
android:apiKey="0Vy8telYm-Lv2juDesOUO5rwWuG2VM2SpiD8vmA" />

</RelativeLayout>

-----------------------------------------------------------------------------------------------------------------------------

GMapsActivity.java
-----------------------

public class GMapsActivity extends MapActivity {

private MapView mapView;

private static final int latitudeE6 = 37985339;
private static final int longitudeE6 = 23716735;

@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.main);

mapView = (MapView) findViewById(R.id.map_view);
mapView.setBuiltInZoomControls(true);
mapView.setSatellite(true);
List<Overlay> mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(R.drawable.icon);
CustomItemizedOverlay itemizedOverlay = new CustomItemizedOverlay(drawable, this);

GeoPoint point = new GeoPoint(latitudeE6, longitudeE6);
OverlayItem overlayitem = new OverlayItem(point, "Hello", "I'm in Athens, Greece!");

itemizedOverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedOverlay);

MapController mapController = mapView.getController();

mapController.animateTo(point);
mapController.setZoom(6);

}

@Override
protected boolean isRouteDisplayed() {
return false;
}

}
---------------------------------------------------------------------------------------------------------------------------------

CustomItemizedOverlay.java
=========================

package com.javacodegeeks.android.googlemaps;

import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

public class CustomItemizedOverlay extends ItemizedOverlay<OverlayItem> {

private ArrayList<OverlayItem> mapOverlays = new ArrayList<OverlayItem>();

private Context context;

public CustomItemizedOverlay(Drawable defaultMarker) {
super(boundCenterBottom(defaultMarker));
}

public CustomItemizedOverlay(Drawable defaultMarker, Context context) {
this(defaultMarker);
this.context = context;
}

@Override
protected OverlayItem createItem(int i) {
return mapOverlays.get(i);
}

@Override
public int size() {
return mapOverlays.size();
}

@Override
protected boolean onTap(int index) {
OverlayItem item = mapOverlays.get(index);
AlertDialog.Builder dialog = new AlertDialog.Builder(context);
dialog.setTitle(item.getTitle());
dialog.setMessage(item.getSnippet());
dialog.show();
return true;
}

public void addOverlay(OverlayItem overlay) {
mapOverlays.add(overlay);
this.populate();
}

}
maulik6758
Freshman
Freshman
 
Posts: 4
Joined: Wed Apr 13, 2011 7:55 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 2 guests