Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-773] map problems (annotation zIndex + zoom out crash)

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:54:12.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.3.0
ComponentsiOS
Labelsn/a
ReporterNolan Wright
AssigneeBlain Hamon
Created2011-04-15T02:36:06.000+0000
Updated2011-04-17T01:54:12.000+0000

Description

premium ticket:

http://helpdesk.appcelerator.net/tickets/1871">http://helpdesk.appcelerator.net/tickets/1871

two issues

1) click on the bottom right annotation, you will see that the pin above it obscures part of the annotation (something like a zIndex problem)

2) clicking zoom out repeatedly will cause a crash. seems to be related to doing a zoom out when you can't zoom out any farther.

here's the code you can drop into app.js


   var win= Ti.UI.createWindow();
   win.title = 'Map View Bug Demo';
   
   var testState = 0;
   
   var m0 = [47.608941,-122.340145,'3/27/2010 22:13','Jumping bush cricket','1521 1st Ave Seattle'];
   var m1 = [47.613591,-122.344394,'3/27/2010 22:13','Common true katydid','2222 2nd Ave Seattle'];
   var m2 = [47.624562,-122.356442,'3/27/2010 22:13','Fall field cricket','14 Mercer St Seattle'];
   var m3 = [47.606366,-122.337656,'3/27/2010 22:13','Fork-tailed bush katydid 1','1225 1st Ave Seattle'];
   var m4 = [47.612825,-122.34567,'3/27/2010 22:13','Fork-tailed bush katydid 2','2230 1st Ave Seattle'];
   var m5 = [47.605961,-122.34036,'3/27/2010 22:13','Greater anglewing','1301 Alaskan Way Seattle'];
   var m6 = [47.613975,-122.345467,'3/27/2010 22:13','Greater anglewing katydid 1','2234 2nd Ave Seattle'];
   var m7 = [47.617215,-122.326584,'3/27/2010 22:13','Greater anglewing katydid 2','1416 E Olive Way Seattle'];
   var m8 = [47.610127,-122.342838,'3/27/2010 22:13','Lesser anglewing','1908 Pike Place Seattle'];
   var m9 = [47.624562,-122.356442,'3/27/2010 22:13','Oblong-winged katydid','14 Mercer St Seattle'];
   var markers = [m0,m1,m2,m3,m4,m5,m6,m7,m8,m9];

   //
   // CREATE ANNOTATIONS
   //
   var myAnnotations = [];

   function clearAnnotations(){
       for (i=myAnnotations.length-1;i>=0;i--) {
           mapview.removeAnnotation(myAnnotations[i]);//if any exist from reading DB
       }
       myAnnotations = [];
   }

   function addAnnotations() {
       for (i=0;i<markers.length-1;i++){
           dbMarker = Titanium.Map.createAnnotation({
               animate:true,
               rightButton:Titanium.UI.iPhone.SystemButton.DISCLOSURE,
               pincolor:Titanium.Map.ANNOTATION_PURPLE,
               latitude:markers[i][0],  //latitude
               longitude:markers[i][1],  //longitude
               title:markers[i][3],  //cricket name
               subtitle:markers[i][2],  //date
               comment:markers[i][4]  //comment - custom parameter
            });
           //Titanium.API.info('Row:' + i + ', longitude:' +longitude+', latitude:'+latitude);
           myAnnotations.push(dbMarker);
       }
       for (i=0;i<myAnnotations.length;i++){
           mapview.addAnnotation(myAnnotations[i]); //put pin on map
       }
   }
   
   function flagAnnotations(theTestState){
       //  change the annotation on the fly
       for (i=myAnnotations.length-1;i>=0;i--) {
           if(theTestState == 2){//change to new annotation properties
                myAnnotations[i].pincolor=Titanium.Map.ANNOTATION_RED;
                myAnnotations[i].leftButton='../images/appcelerator_small.png';
                myAnnotations[i].rightButton='../images/apple_logo.jpg';
            } else if(theTestState == 1){ //restore original annotation properties
                myAnnotations[i].pincolor=Titanium.Map.ANNOTATION_PURPLE;
                myAnnotations[i].leftButton=null; //replace prior image
                myAnnotations[i].rightButton=Titanium.UI.iPhone.SystemButton.DISCLOSURE;
            } else {
               Titanium.UI.createAlertDialog({title:'Logi error',message:'flagAnnotations() has bad parameter'}).show();
           }
       }
   }

   //
   // CREATE MAP VIEW
   //
   mapview = Titanium.Map.createView({
       mapType:Titanium.Map.STANDARD_TYPE,
       region:{latitude:47.612825, longitude:-122.34567, animate:true, latitudeDelta:0.01, longitudeDelta:0.01},
       animate:true,
       regionFit:true,
       userLocation:true
       //annotations:[]
   });
   win.add(mapview);
   
   // map view click event listener
   mapview.addEventListener('click',function(evt) {
       // map event properties
       Titanium.API.info('MAPVIEW EVENT');
    
       var annotation = evt.annotation;
       var clickSource = evt.clicksource;
       var comment = annotation.comment;
   
       if (clickSource == 'rightButton') {
           if (testState==2){//State#2
               Titanium.UI.createAlertDialog({title:'right Button State #2',message:'rightButton click while in State#2'}).show();
          } else if (testState==1) {//show the marker's comment
               Titanium.UI.createAlertDialog({title:'right Button State #1',message:comment}).show();
           }
       }
       if (clickSource == 'leftButton') {
           if (testState==2){//user can use new button
                Titanium.UI.createAlertDialog({title:'left Button State #2',message:'leftButton click while in State#2'}).show();
            }
       }
   });
   
   
   //
   // TOOLBAR BUTTONS
   //
   var state0 = Titanium.UI.createButton({
       style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED,
       title:'Init State 1'
   });

   var state1 = Titanium.UI.createButton({
       style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED,
       title:'To State 2'
   });
   
   var state2 = Titanium.UI.createButton({
       style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED,
       title:'Back To State 1'
   });
   
   state0.addEventListener('click', function(){
       testState = 1;
       clearAnnotations();
       addAnnotations();
       state0.enabled = false;
       state1.enabled = true;
       state2.enabled = false;
   });
   state1.addEventListener('click', function(){ //go to state 2
       testState = 2;
       state0.enabled = false;
       state1.enabled = false;
       state2.enabled = true;
       flagAnnotations(testState); //change the annotation on the fly
   });
   
   state2.addEventListener('click', function(){ //back to state 1
       testState = 1;
       state0.enabled = true;
       state1.enabled = false;
       state2.enabled = false;
       flagAnnotations(testState); //change the annotation on the fly
   });
   
   state0.enabled = true;
   state1.enabled = false;
   state2.enabled = false;
   
   
   var flexSpace = Titanium.UI.createButton({
    systemButton:Titanium.UI.iPhone.SystemButton.FLEXIBLE_SPACE
   });
   
   // button to zoom-in
   var  zoomin = Titanium.UI.createButton({
        title:'+',
        style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED
    });
   zoomin.addEventListener('click',function(){
    mapview.zoom(1);
   });

   // button to zoom-out
   var  zoomout = Titanium.UI.createButton({
        title:'-',
        style:Titanium.UI.iPhone.SystemButtonStyle.BORDERED
    });
   zoomout.addEventListener('click',function(){
    mapview.zoom(-1);
   });
   
   
   var tb = Ti.UI.createToolbar({
    height:44,
    bottom:0,
    items:[flexSpace,state0,flexSpace,state1,flexSpace,state2,flexSpace,zoomin,flexSpace,zoomout,flexSpace]
   });

   win.add(tb);

   win.open();

Comments

  1. Jeff Haynie 2011-04-15

    (from [274b3c1f8bd76274c21222ea9cffe707ded1c0bd]) Closes #773 in both issues http://github.com/appcelerator/titanium_mobile/commit/274b3c1f8bd76274c21222ea9cffe707ded1c0bd"> http://github.com/appcelerator/titanium_mobile/commit/274b3c1f8bd76...

JSON Source