2016-02-14 100 views
1

我使用ti.Map停止通过点击事件注释(从弹出阻止)

我想要做的事,当用户点击注释。

//make mapview 
    var mapView = Map.createView({ 
     mapType:Map.NORMAL_TYPE, 
    }); 

//make anotation 
    annot= Map.createAnnotation({ 
      latitude: myLatitude 
      longitude: myLongitude 
      title: myTitle 
      width:'100dp', 
      height:'100dp' 
    }); 

// add annotation 
    mapView.addAnnotation(annot); 

//handle the annotation click 
    mapView.addEventListener('click', function(evt) { 
     if (evt.clicksource == "pin"){ // if user click annotation 
      //do something 
      return; //I try this 
     } 
    }); 

它运作良好。

然而,做一些事情之后,注释弹出窗口(如默认行为)

我想停下来注释弹出。

1)我尝试阻止传递给注记类的事件。

2)停止注释不反应点击事件。

我该如何解决?

回答

1

如果您想停止注释弹出窗口,请尝试对annot的属性title发表评论。我试过这个,它的工作正常。

//make anotation 
annot= Map.createAnnotation({ 
     latitude: 19.151201, 
     longitude: 72.938237, 
     // title: 'myTitle', 
     width:'100dp', 
     height:'100dp' 
}); 

//handle the annotation click 
mapView.addEventListener('click', function(evt) { 
    if (evt.clicksource == "pin"){ // if user click annotation 
     //do something 
     alert('Pin clicked'); 
     return; //I try this 
    } 
}); 

而只是警告是不可见的注释弹出。

一些更新的代码:

annot= Map.createAnnotation({ 
    latitude: 19.151201, 
    longitude: 72.938237, 
    title: ' ', 
    backgroundColor : 'transparent' 
}); 
// add annotation 
mapView.addAnnotation(annot); 

//handle the annotation click 
mapView.addEventListener('click', function(evt) { 
if (evt.clicksource == "pin"){ // if user click annotation 
    alert('Pin clicked'); 
    evt.annotation.title = ""; 
    // return; //I try this 
}else if (evt.clicksource == "map"){ 
    alert('map'); 
    evt.annotation.title = " "; 
} 
}); 
+0

感谢您的评论。我评论了标题,所以弹出窗口不出来,但不知何故“点击”事件的mapView不会被解雇.... – whitebear

+0

@whitebear您正在使用哪个SDK? – Swanand

+0

5.1.1GA和ti图2.4.1(iOS) – whitebear