MapView annotations z-ordering / layering

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

I'm getting started using the map view in Titanium.Map, using the Kitchen Sink example to start out.

At first I had trouble with mapview.addAnnotation — it looks like you cannot call this function except from inside certain event handlers (?), perhaps once the view has been all set up. This slightly-modified snippet from the KS does not work:

var mapview = Titanium.Map.createView({
    mapType: Titanium.Map.STANDARD_TYPE,
    region: {latitude:33.74511, longitude:-84.38993, latitudeDelta:0.01, longitudeDelta:0.01},
    animate:true,
    regionFit:true,
    userLocation:true,
    annotations:[]
});
 
mapview.addAnnotation(apple);
mapview.addAnnotation(atlanta);
win.add(mapview);
In any case, now I am adding my pins/annotations to the map using a button but after adding a bunch of annotations I noticed the z-ordering is wrong. When you click to view an annotation, this element is not "brought to front".

mapview example

Is there some way I can fix this, perhaps by binding an event handler and setting some view attributes somehow? Or does it need fixing inside of Titanium? Thanks!

P.S. I'm not an objc developer, but this stackoverflow thread might explain what's wrong?

— asked 3 years ago by chris e
0 Comments

4 Answers

An answer to Glenn's question: I am calling addAnnotation from a click event (on a button in the same window as the map), and that seems to work. It seems like the map view needs to be loaded and displayed before you can successfully call addAnnotation — so you can't call addAnnotation a few lines after you add the map view to your window.

You might try setting different events (or using fireEvent) to get addAnnotation to work for what you're doing.

I dont have an exact awnser for you but more like a question.

How did you managed to get the mapview.addAnnotation() to work properly? Im trying to get this to work for serveral hours now, but without any luck.

And do you you know from what eventhandlers you can call them?

I have the same probem, getting this error:

[TRACE] I/KrollObject( 2686): (kroll$2) [16,6797] Treating as dynamic property: addAnnotation [TRACE] I/KrollObject( 2686): (kroll$2) [8,6805] Treating as dynamic property: noSuchMethod [TRACE] D/dalvikvm( 2686): GC freed 5657 objects / 385896 bytes in 95ms [TRACE] E/KrollContext( 2686): (kroll$2) [323,7128] Error evaluating source: TypeError: Cannot call property addAnnotation in object ti.modules.titanium.map.ViewProxy@43bdf4a8. It is not a function, it is "object". [TRACE] E/KrollContext( 2686): org.mozilla.javascript.EcmaError: TypeError: Cannot call property addAnnotation in object ti.modules.titanium.map.ViewProxy@43bdf4a8. It is not a function, it is "object".

i know it's a little old thread but i have an answer and a question

in iphone addannotation must be called after you add the view to a win (ie after it's displayed)

and my question is

did you find a solution for the ordering problem ?

i have the exact same problem with route .. route is displayed over the popup

Thanks in Advance

Your Answer

Think you can help? Login to answer this question!