hansemannn / titanium-googlemaps

🗺 Use the Google Maps SDK in Titanium
Other
87 stars 26 forks source link

App crashes when adding an annotation #81

Closed stefanovic72 closed 7 years ago

stefanovic72 commented 7 years ago

Hi, I'm not sure whether this is a module issue. probably not. I use module version 3.2.0. Titanium SDK 6.0.1.

I've generated an API KEY and enabled the Google maps SDK for Ios. After setting the APIKey i create a mapview. The map is shown in my app. In the Google API console I can see the request that is done, so the connection with the Google API works. So far so good.

But...when I try to add an annotation, the app crashes. There is nothing written in the console, no error message.

I have first tried it inside a custom app. Then I created a test app with the exact same code as in the provided example (example/app.js). The test app crashes as well.

Any idea what the cause can be?

hansemannn commented 7 years ago

Can you check if toggling the main-thread changes something:

  <property name="run-on-main-thread" type="bool">true</property>

vs.

  <property name="run-on-main-thread" type="bool">false</property>
hansemannn commented 7 years ago

I think either @yozef or @m1ga had something related a few weeks ago?

stefanovic72 commented 7 years ago

I had already tried that since i saw something similar in another issue indeed. I now tried it once again. run-on-main-thread false or true does not make a difference.

hansemannn commented 7 years ago

Can you provide the exact demo-code or even whole project? And the iOS + SDK version you're testing with.

stefanovic72 commented 7 years ago

test_ti_googlemaps.zip

iOS 10.1 SDK 6.0.1. module version 3.2.0.

stefanovic72 commented 7 years ago

When I comment out line 172 in app.js (mapView.addAnnotation(annotation)) the map is being shown.

hansemannn commented 7 years ago

Wait. There is a lot of unused / unrelated code there. Does this crash (it doesn't for me):

var maps = require("ti.googlemaps");

/**
 *  SET YOUR API-KEY BEFORE USING THIS MODULE
 */
maps.setAPIKey("AIzaSyAbjmJ1RSHQCxvtTG6APBVv9rn3h71qwYo");

var win = Ti.UI.createWindow({
    title: "Ti.Googlemaps"
});

var nav = Ti.UI.iOS.createNavigationWindow({
    window: win
});

/*
 *  Test data
 */
var companies = {
    appcelerator: {
        title: "Appcelerator",
        city: "San Jose, CA",
        latitude: 37.368122,
        longitude: -121.913653
    },
    apple: {
        title: "Apple",
        city: "Cupertino, CA",
        latitude: 37.331711,
        longitude: -122.030184
    },
    facebook: {
        title: "Facebook",
        city: "Menlo Park, CA",
        latitude: 37.4748624,
        longitude: -122.1490817
    },
    microsoft: {
        title: "Microsoft",
        city: "Redmond, WA",
        latitude: 47.641959,
        longitude: -122.130588
    }
};

/*
 *  MapView
 */
var mapView = maps.createView({
    region: {
        latitude: companies.appcelerator.latitude,
        longitude: companies.appcelerator.longitude,
        zoom: 10
    }
});

/*
 *  Marker
 */
for (var key in companies) {
    if (companies.hasOwnProperty(key)) {
        var company = companies[key];

        var annotation = maps.createAnnotation({
            latitude: company.latitude,
            longitude: company.longitude,
            title: company.title,
            subtitle: company.city
        });

        mapView.addAnnotation(annotation);

        Ti.API.warn(key + ": " + company.title + " (" + company.city + ")");
    }
}

win.add(mapView);
nav.open();

Also note to not use addMarker (anything with "xxxMarker"). That API has been deprecated in 2.x and been removed in 3.0.0. Only use addAnnotation etc.

stefanovic72 commented 7 years ago

Hi, I copied the code and tried again. App is still crashing with this code. I also tested on the device. When it works at your side it looks like it has something to do with my environment.... Any other suggestions?

stefanovic72 commented 7 years ago

I just noticed that i use an older version of xcode (8.1). I'll update Xcode and let you know if that helps

stefanovic72 commented 7 years ago

Nope, updates XCode 8.2.1: same thing...

hansemannn commented 7 years ago

Sorry, no more ideas. If even the trace-log (appc run -p ios --log-level trace) doesn't bring any logs, there is nothing I can do right now.

m1ga commented 7 years ago

My app was crashing with the old version and running on main thread. But the latest version (3.2.2 now) was displaying all example files without any problem (SDK 6.0.1). Did you copy over the images? Does the cluster example work for you (be sure to zoom in)? It will display custom markers at first and at the end it will display the normal pin.

hansemannn commented 7 years ago

Please try 3.2.2, I'll close for now, thx!

stefanovic72 commented 7 years ago

Thanks very much for helping me with this. Unfortunately, i'm still facing the same problem (even in 3.3.0). Strange but true...

hansemannn commented 7 years ago

Duplicate of #83