titanium-mapbox icon indicating copy to clipboard operation
titanium-mapbox copied to clipboard

bug annotation

Open jeromehanse opened this issue 9 years ago • 6 comments

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!

jeromehanse avatar Aug 07 '15 11:08 jeromehanse

+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

ilker55 avatar Jul 20 '16 07:07 ilker55

@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.

Abdelalim-dev avatar Jul 30 '16 11:07 Abdelalim-dev

@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).

ilker55 avatar Aug 01 '16 07:08 ilker55

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 avatar Aug 05 '16 15:08 Abdelalim-dev

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.

Abdelalim-dev avatar Aug 05 '16 15:08 Abdelalim-dev

@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.

ilker55 avatar Sep 12 '16 14:09 ilker55