Not all map events fire?

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

With the following setup only three events seem to fire on the simulator:

var map = Titanium.Map.createView({
    mapType           : Titanium.Map.STANDARD_TYPE,
    region : {
        latitude      : 37.3317,
        longitude     : -122.0307,
        latitudeDelta : 0.5,
        longitudeDelta: 0.5
    },
    animate           : true,
    regionFit         : true,
    userLocation      : true
});
Ti.UI.currentWindow.add(map);
map.addEventListener('click', function(){
    Titanium.API.info("MAP: click");
});
map.addEventListener('complete', function(){
    Titanium.API.info("MAP: complete");
});
map.addEventListener('dblclick', function(){
    Titanium.API.info("MAP: dblclick");
});
map.addEventListener('doubletap', function(){
    Titanium.API.info("MAP: doubletap");
});
map.addEventListener('loading', function(){
    Titanium.API.info("MAP: loading");
});
map.addEventListener('regionChanged', function(){
    Titanium.API.info("MAP: regionChanged");
});
map.addEventListener('singletap', function(){
    Titanium.API.info("MAP: singletap");
});
map.addEventListener('swipe', function(){
    Titanium.API.info("MAP: swipe");
});
map.addEventListener('touchcancel', function(){
    Titanium.API.info("MAP: touchcancel");
});
map.addEventListener('touchend', function(){
    Titanium.API.info("MAP: touchend");
});
map.addEventListener('touchmove', function(){
    Titanium.API.info("MAP: touchmove");
});
map.addEventListener('touchstart', function(){
    Titanium.API.info("MAP: touchstart");
});
map.addEventListener('twofingertap', function(){
    Titanium.API.info("MAP: twofingertap");
});
Output:
[INFO] MAP: loading
[INFO] MAP: complete
[INFO] MAP: regionChanged
I realized this since I couldn't get the 'click' event to work. Anything I'm doing wrong here?

P.S.: Apologies for the questions flood. Figure these might be things other developers will be looking for as well in the near future, though.

— asked 3 years ago by Florian Plank
2 Comments
  • I used your js, and i my log there is only [INFO] MAP: regionChanged

    :(

    i'm using titanium sdk 1.3 and tested on all android versions (from 1.6 to 2.2)

    — commented 3 years ago by Alessio Grumiro

  • same code on iphone 3.1 sdk prints

    [INFO] MAP: regionChanged [INFO] MAP: loading [INFO] MAP: complete

    — commented 3 years ago by Alessio Grumiro

6 Answers

Thanks for your answer!

If that's the case, the following line from the documentation is pretty misleading IMO, though:

EVENTS:
click :  fired when a map view or annotation is touched
( https://developer.appcelerator.com/apidoc/mobile/1.1/Titanium.Map.MapView )

The click event for example works only on annotations. Its working fine for me.

mapview.addEventListener('click',function(evt) {
        var annotation = evt.annotation;
        var clickSource = evt.clicksource;
        var myid = evt.annotation.myid;
 
        if (myid == source.id && evt.clicksource == 'rightButton') {
            evt.annotation.subtitle = 'subtitle updated';
        }
    });
 
}

I used js in first comment, and i my log there is only [INFO] MAP: regionChanged :( i'm using titanium sdk 1.3 and tested on all android versions (from 1.6 to 2.2)

@ Alessio: This snippet was only written to demonstrate possibly missing events.

What are you trying to achieve and what does not work?

— answered 3 years ago by Florian Plank
answer permalink
1 Comment
  • i've same problem. I'm using loading and complete events on mapView, and that events aren't fired on my android. On iphone loading and completes events are fired after regionChanged. In doc, i've readed regionChanged is fired after map region changed, but it doesn't works.

    — commented 3 years ago by Alessio Grumiro

same code on iphone 3.1 sdk prints

[INFO] MAP: regionChanged [INFO] MAP: loading [INFO] MAP: complete

Your Answer

Think you can help? Login to answer this question!