Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug annotation #22

Open
jeromehanse opened this issue Aug 7, 2015 · 6 comments
Open

bug annotation #22

jeromehanse opened this issue Aug 7, 2015 · 6 comments

Comments

@jeromehanse
Copy link

Hello,

I try to add annotations on my mapView, but it doesn't work.
Here the simple code : http://pastebin.com/hjFfCaZE
Error : "nil argument" ... Ok but what argument?

Do you have any idea how to resolve this?

Thanks!

@ilker55
Copy link
Contributor

ilker55 commented Jul 20, 2016

+1

I know it's an old thread, but I got the same problem.
My code:

        var Map = require('com.polancomedia.mapbox');

        var mapFile = Titanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory, 'custom-world-6.mbtiles');
        Ti.App.Map = Map.createView({
            map: mapFile,
            minZoom: 0,
            maxZoom: 6,
            zoom: 2,
            accessToken: 'xxxxx', //REQUIRED!!!
            centerLatLng: [37.322831,7.490234],
            width: Ti.UI.FILL,
            height: Ti.UI.FILL,
            hideAttributes: true,
            userLocation: true
        });

        var a1 = Map.createAnnotation({
            latitude: 18.467354,
            longitude: -91.903534,
            title: "Test Title",
            subtitle: "Subtitle"
        });
        Ti.App.Map.addAnnotation(a1); // Crashes here

With the following error code when adding a annotation:

screen shot 2016-07-20 at 09 44 29

*** -[__NSCFConstantString stringByAppendingString:]: nil argument

Using Titanium SDK 5.3.1.GA and iOS 9.3

@Abdelalim-dev
Copy link

@ilker55 I've come across the same issue.
I used
Ti.App.Map.addAnnotations([a1]);
Although that solved the crash issue for me but I couldn't add any annotations on the map!
Any ways, try it out and tell me if it works.

@ilker55
Copy link
Contributor

ilker55 commented Aug 1, 2016

@Abdelalim-dev When I use addAnnotations I get:
undefined is not a function (evaluating 'Ti.App.Map.addAnnotations([ a1 ])')
And I don't see addAnnotations anywhere in the documentation (https://github.com/adampax/titanium-mapbox/wiki/Annotations).

@Abdelalim-dev
Copy link

To be on the same page make sure you are using the same map module I'm using (ti.map).
You can check for the latest releases here (https://github.com/appcelerator-modules/ti.map/releases)

@Abdelalim-dev
Copy link

To solve the issue of annotations not showing on the map (Android) I used a custom view instead of a simple image like so:

if (OS_IOS) {
    annotation.image = image, //your image goes here
    annotation.canShowCallout = false;
} else {
    annotation.customView = Ti.UI.createLabel({
        width : 44,
        height : 56,
        backgroundImage : image,//your image goes here
    });
}

You can then add the annotation to the map.

@ilker55
Copy link
Contributor

ilker55 commented Sep 12, 2016

@Abdelalim-dev
To be on the same page make sure you are using the same map module I'm using (ti.map).

But i'm using the map-box module (com.polancomedia.mapbox) so ti.map annotations don't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants