Issue
I'm trying to implement google maps V2 but the maps is showing blank. I've edited the manifest, created xml layout and the activity but maps is showing blank.
Here is what i did to the manifest:
<permission
android:name="com.biznismap.com.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.biznismap.com.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
and added this in as the first child of application node in the manifest:
<uses-library android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="my_key" />
Here is my map xml layout:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="my_key"
android:clickable="true" />
Here is my MapActivity:
public class ListingMap extends MapActivity {
private HelloItemizedOverlay itemizedoverlay;
private List<Overlay> mapOverlays;
private String lat, lng;
@Override
protected boolean isRouteDisplayed() {
return false;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listing_map);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapOverlays = mapView.getOverlays();
Drawable drawable = this.getResources().getDrawable(
R.drawable.ic_launcher);
itemizedoverlay = new HelloItemizedOverlay(drawable);
getExtras();
}
private void getExtras() {
Bundle extras = getIntent().getExtras();
lat = extras.getString("lat");
lng = extras.getString("lng");
Log.v("--", lat+" "+lng);
float latitude=Float.valueOf(lat);
float longitude=Float.valueOf(lng);
GeoPoint point = new GeoPoint((int)(latitude * 1E6),(int)(longitude * 1E6));
OverlayItem overlayitem = new OverlayItem(point, "Hola, Mundo!",
"I'm in Mexico City!");
itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
}
}
So everything is going OK but, when I want to display something, the map is blank, and I get this from the emulator:
06-02 17:09:26.921: E/MapActivity(1772): Couldn't get connection factory client
So where am I going wrong, and how can I fix this problem?
Solution
Here is what https://developers.google.com/maps/documentation/android/v1/hello-mapview says:
Note: Version 1 of the Google Maps Android API has been officially deprecated as of December 3rd, 2012. This means that from March 18th, 2013 you will no longer be able to request an API key for this version. No new features will be added to Google Maps Android API v1. However, apps using v1 will continue to work on devices. Existing and new developers are encouraged to use Google Maps Android API v2.
Your code is miximg v1 and v2 properties.
Answered By - Alex
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.