MapView shows empty grid in Android

You must Login before you can answer or comment on any questions.

I'm trying to show a mapview in my Android app however it's just a blank grid, no map is shown. I have a google maps api key specified in my tiapp.xml like so:

<property name="ti.android.debug" type="bool">false</property>
  <property name="ti.android.google.map.api.key.development">devkey</property>
  <property name="ti.android.google.map.api.key.production">productionkey</property>
</ti:app>
What am I missing?

4 Answers

For some reason on the simulator the kitchen sink api key works but my own doesn't so I changed my dev key to kitchen sink's and now the map loads up. However, if I try to load an annotation on the map then the entire app crashes:

function displayMap() {
    //create annotation.
    var annotation = createMapAnnotation();
    //create map.
    var mapView = Titanium.Map.createView({
        mapType: Titanium.Map.STANDARD_TYPE,
        region: { latitude: 39.469688, longitude: -76.637808, latitudeDelta: 0.5, longitudeDelta: 0.5 },
        animate: true, regionFit: true, userLocation: true,
        top: 85, bottom: 65
        ,annotations:[annotation]
    });
    if (!isAndroid) {
        mapView.addAnnotation(annotation);
    }
    mapView.selectAnnotation(annotation);
    win.add(mapView);
    //create menu.
    createMapMenu();
}
 
function createMapAnnotation() {
    var annotationParams = {
        latitude: 39.469688,
        longitude: -76.637808,
        title: vehicle.vehicle,
        subtitle: vehicle.ipaddress,
        animate: true,
        //pincolor: Titanium.Map.ANNOTATION_PURPLE,
        //leftButton: '../images/atlanta.jpg',
        //rightButton: Titanium.UI.iPhone.SystemButton.DISCLOSURE,
        myid: 1 // CUSTOM ATTRIBUTE THAT IS PASSED INTO EVENT OBJECTS
    };
//    if (!isAndroid) {
//        annotationParams.pincolor = Titanium.Map.ANNOTATION_PURPLE;
//    } else {
//        annotationParams.pinImage = path + "images/pin.png";
//    }
    return Titanium.Map.createAnnotation(annotationParams);
}
The logging shows:

[TRACE] W/Maps.MyLocationOverlay( 1251): Couldn't get provider gps: Requires ACCESS_FINE_LOCATION permission [TRACE] W/Maps.MyLocationOverlay( 1251): Couldn't get provider network: Requires ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION permission [TRACE] W/Maps.MyLocationOverlay( 1251): None of the desired Location Providers are available [TRACE] D/AndroidRuntime( 1251): Shutting down VM etc...

Any ideas?

Got it working, i was setting the subtitle to an integer instead of a string, doh!

I tried to copy KitchenSink's dev key to my app. On the emulator it works in the 50% of time, but it worked not a single time on my ZTE Blade. Shall it work anyways with KitchenSink's key?

You need your correct Google KEY and modify AndroidManifest.xml as explain here: http://developer.appcelerator.com/question/121105/crash-in-android-when-using-maps

Also you need a device with Internet access to display the map instead an empty grid. Include this in your AndroidManifest.xml also:

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

Your Answer

Think you can help? Login to answer this question!