The google map looks empty inside the simulator - android

public class Map extends MapActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
MapView mapView = (MapView) findViewById(R.id.myMapView1);
mapView.getController().animateTo(srcGeoPoint);
mapView.getController().setZoom(15);
}
the map.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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/myMapView1"
android:layout_width="fill_parent"
android:layout_x="0px"
android:enabled="true"
android:clickable="true"
android:apiKey="Obtained Key here" android:layout_y="105px" android:layout_height="fill_parent">
</com.google.android.maps.MapView>
</LinearLayout>
I check the log there's only one red mark, Failed to find provider info for com.google.settings. everything else seems to be fine. I am wondering why the map is empty looking?

The MapView is empty when your Maps API key is expired or not matching with your debug signature key.
Try to generate a new one.

Inside every MapActivity, the isRouteDisplayed() method is required,
so override this method:
#Override protected boolean isRouteDisplayed() {
return false; }
This method is required for some accounting from the Maps service to
see if you're currently displaying any route information. In this
case, you're not, so return false.
source: http://developer.android.com/resources/tutorials/views/hello-mapview.html
Additional the android:layout_x="0px looks a little bit dodgy to me. I think it's only used in AbsoluteLayouts so deleting it should not harm.

Please check logs whether you are not getting "unable to authenticate error from google server". If yes there is issue with map key.
Map key should be generate on same system where you are running application.
Also check whether you have google play account signed and location setting is enabled.
please check here for more details:
https://developers.google.com/maps/documentation/android/start

Related

How to Move over to Maps V2 from V1 when using MapView

So before, we were able to do something like this:
package com.bignerdranch.android.taskmanager;
import android.os.Bundle;
import com.google.android.maps.MapActivity;
public class AddLocationMapActivity extends MapActivity {
public static final String ADDRESS_RESULT = "address";
#Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.add_location);
}
#Override
protected boolean isRouteDisplayed() {
return false;
}
#Override
protected boolean isLocationDisplayed() {
return true;
}
}
Along with the layout class:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/location_title"
.../>
<EditText
android:id="#+id/task_address"
.../>
<Button
android:id="#+id/map_location_button"
.../>
<com.google.android.maps.MapView
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/map_location_button"
android:layout_above="#+id/use_this_location_button"
android:clickable="true"
android:apiKey="AIza..............................." />
<Button
android:id="#id/use_this_location_button"
.../>
</RelativeLayout>
But now this won't work with V1 keys, so my question is how can I change this to make it work with V2 keys? I've read that I should use fragments but I'm new to android programming so I don't know how to code it, and still make my application work as intended.
Thanks!!
But now this won't work with V1 keys, so my question is how can I change this to make it work with V2 keys?
Throw away all that code and use the Maps V2 SDK. Maps V1 cannot use Maps V2 keys.
This should have displayed a map in which you could move around, but because of the deprecated V1 keys, it no longer works.
Maps V1 has been deprecated for a fairly long time. It's been nearly 4 years since you could even get Maps V1 keys, and Maps V1 had been considered deprecated for a while before that.

osmdroid MapTileDownloader now showing 403 forbidden as HTTP response

I have successfully been using osmdroid-android-4.1.jar for a while to display OSM map tiles in my app.
Now, since yesterday, I don't get any tiles at all displayed. When I connect my phone to the PC I see the 403 forbidden response in the log. I built the app on an Ubuntu machine using Android Studio. I haven't got a good understanding of .aar file yet, could it be that the 4.1jar is now outdated and not setting the correct user-agent?
I know Mapquest isn't supported now but I'm using Mapnik tiles
All information gratefully received
Update
I've just tried an old Eclipse based project on my Windows PC. That uses 4.1 jar and I ran it in an emulator. I see the same 403 response and no map tiles. The tile source is
mMapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
I know this project used to work. The cache tiles show Ok but if I move the map - no tiles.
The entire code is
public class OsmdroidDemoMap extends Activity {
private MapView mMapView;
private MapController mMapController;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.osm_main);
mMapView = (MapView) findViewById(R.id.mapview);
mMapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
mMapView.setBuiltInZoomControls(true);
mMapController = (MapController) mMapView.getController();
mMapController.setZoom(13);
GeoPoint gPt = new GeoPoint(51500000, -150000);
mMapController.setCenter(gPt);
}
}
/* HAVE THIS AS YOUR osm_main.xml
---------------------------------------------------------- XML START
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<org.osmdroid.views.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:clickable="true" />
</LinearLayout>
---------------------------------------------------------- XML END
Include slf4j-android-1.5.8.jar and osmdroid-android-4.1.jar in the build path
(Google search for where to get them from)
*/
I have posted this code before as an answer and as an example of the smallest working osmdroid sample - well it isn't a working example now!
We had the same issue today.
In build.gradle we changed this:
compile files('libs/osmdroid-android-4.2.jar')
to:
compile 'org.osmdroid:osmdroid-android:5.1#aar'
And added this:
OpenStreetMapTileProviderConstants.setUserAgentValue(BuildConfig.APPLICATION_ID);
before loading the map.
You can read more about the issue here:
https://github.com/osmdroid/osmdroid/issues/366.
Hope this helps you too!

Android GoogleMap V2 on zoom map doesn't get sharpen

I'm currently working on Android and have started with Google Maps V2 API.
As I have finished going through all their setup guide the map worked and I was able to see the continents. Only problem is that when I zoom in, the map stays the same I just get less pixels untill eventually I get gray squares - as if it has loaded the map but not entirely. I'd been looking around for someone with a problem like mine and couldn't find any.
Any assistance will be appreciated.
My code:
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
public class myMapActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
}
More information:
I had added:
GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
and gotten gray squares without map at all. hope it helps identify the problem Thank you in advance.
As recommended I had uninstalled which probably removed previous save of the map.
After reinstalling the app works fine.

findViewByID all of a sudden returns null

before I posted my problem here, I have been done some researches but none of them helps. The weird part is that it worked last night and I believed nothing has been changed at all. However, I can't make it work now because the findViewByID returns null for no reason
public class ShowInMap extends MapActivity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mapview);
MapView mapView = (MapView) this.findViewById(R.id.mapview);
if(mapView == null)
{
Log.i("test", "test");
}
}
}
and this is my mapview xml
<?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:clickable="true"
android:apiKey="Map Key"
/>
I am thinking maybe my debug key has expired but if that was the case, I should have gotten some errors from Eclipse saying my key is expired or something? Shouldn't I? It is a bit frustrating, any comment would be appreciated. Thank you
Try cleaning the build. This happens to me every-now-and-then. Usually if I just clean the build and then to a complete rebuild, things seem to work.

com.google.android.maps

Since few days my application does not show maps anymore.
To make sure my code is right, I decided to test the MAPS Tutorials
application found in developer.android.com here.
The maps on the tutorial does not show either.
I just see the usual little grids of the Mapview.
When I tap it I have the normal response telling me the corresponding Geocodes.
Any idea why ??
The code of the tutorial is this one:
public class MapsActivity extends MapActivity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.mapview);
MapView mapView = (MapView) findViewById(R.id.mapView);
mapView.setBuiltInZoomControls(true);
}
#Override
protected boolean isRouteDisplayed() {
return false;
}
}
?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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="my key"
/>
Generally if your map only shows a grid and no tiles you are mixing a release apk with a debug api key or vice-versa.

Categories

Resources