1

マップ ビュー ベース アプリケーションを作成します。私はやってみたいです。rightButtonをクリックすると、アドレスが表示されます。しかし、ボタンがクリックされているかどうかをどのように観察しますか?

私が取る通常のボタンの場合

button.addEventListener('click',function(){
<do something>
});

しかし、mapViewでは、どうすれば取得できますか?

4

2 に答える 2

1

注釈にボタンを配置したいと思います。

注釈のパラメータを作成します:-

var annotationParams = 
{
latitude:33.74511,
longitude:-84.38993,
title:"Example",
subtitle:'Atlanta Braves Stadium foo',
pincolor: isAndroid ? "orange" : Titanium.Map.ANNOTATION_RED,
animate:true,
myid:1,
leftButton:currentWindow.photo, // for image
rightButton: Titanium.UI.iPhone.SystemButton.DISCLOSURE
};

var mapAnnotation = Titanium.Map.createAnnotation(annotationParams);

var mapview  = Titanium.Map.createView
({
    mapType: Titanium.Map.STANDARD_TYPE,
    region:{latitude:33.74511, longitude:-84.38993, latitudeDelta:0.5, longitudeDelta:0.5},
    animate:true,
    regionFit:true,
    userLocation:true,
    annotations:[mapAnnotation],
    top:'0dp',
    height:'450dp'
});     
currentWindow.add(mapview);

次に、マップビューのクリックを次のように処理します:-

// map view click event listener
mapview.addEventListener('click',function(evt)
{
   if (evt.clicksource == 'rightButton')
   {
    //getDetails();
    createActionSheet();        
   }
   else if(evt.clicksource == 'leftButton')
   {
      // do some thing
   }
 } 
于 2012-03-03T11:56:59.650 に答える
1

これはあなたにとって便利だと思います、

mapview.addEventListener('click', function(evt) {

    Ti.API.info("Annotation " + evt.title + " clicked, id: " + evt.annotation.myid);

    // Check for all of the possible names that clicksouce
    // can report for the left button/view.
    if (evt.clicksource == 'leftButton' || evt.clicksource == 'leftPane' ||
        evt.clicksource == 'leftView') {
        Ti.API.info("Annotation " + evt.title + ", left button clicked.");
    }
});
于 2012-03-03T12:07:02.803 に答える