Titanium - 在注释中存储信息

发布于 2024-12-21 10:06:51 字数 2059 浏览 3 评论 0原文

我正在地图视图上进行多个注释,并且正在打开一个新的详细窗口以进行右键选择。我应该通过标签在详细窗口中显示一些信息,并且每个引脚注释显示的信息都不同。如何将一些数据存储到引脚注释中?帮助我完成这项工作。提前致谢。

这是我的代码.. 注释创建:

    okBtn.addEventListener("click", function(e) {
        Ti.API.info("Text = " + textField.value);
        mapview.removeAllAnnotations();
        Ti.Geolocation.forwardGeocoder(textField.value, function(e) {
            var annotations = [];
            for(var i = 0; i < 10; i++) {
                var pin = Titanium.Map.createAnnotation({
                    latitude : e.latitude-i,
                    longitude : e.longitude-i,
                    animate : true,
                    pincolor : Titanium.Map.ANNOTATION_RED,
                    rightButton : Titanium.UI.iPhone.SystemButton.DISCLOSURE//'rightButton.png'
                });
                annotations[i] = pin;
                // suppose mapView is your map object
                mapview.addAnnotation(annotations[i]);
            }
            var region = {
                latitude : e.latitude,
                longitude : e.longitude,
                animate : true,
                latitudeDelta : 0.15,
                longitudeDelta : 0.15
            };
            mapview.setLocation(region);
            Ti.API.info(e);
        });
    });
var detailWindow = Ti.UI.createWindow({
    backgroundColor : "#fff",
    navBarHidden : true,
    backgroundImage : 'screen.png'
});
var detailTitle = Ti.UI.createLabel({
    color : '#EC6512',
    font : {
        fontSize : 18,
        fontWeight : 'bold',
        fontFamily : 'Arial'
    },
    left : 12,
    top : 60,
    height : 80,
    width : 300,
    clickName : 'detailTitle',
});
detailWindow.add(detailTitle);

我应该将文本添加到 rightButtonEvent 中的 detailTitle 标签中。

rightButton 事件:

mapview.addEventListener('click', function(evt) {
    if(evt.clicksource == 'rightButton') {
        Titanium.API.info('Right button clicked');
        navGroup.open(detailWindow);
    };
});

我需要创建一个标签并发送数据以在标签中显示。

I am making multiple annotations on a mapview and I am opening a new detailWindow for the right button selection. I should show some information in the detailWindow via labels and the information to be shown are different for each pin annotation. How could I store some data to the pin annotation? Help me to make this work. Thanks in advance.

This is my code..
Annotation creation:

    okBtn.addEventListener("click", function(e) {
        Ti.API.info("Text = " + textField.value);
        mapview.removeAllAnnotations();
        Ti.Geolocation.forwardGeocoder(textField.value, function(e) {
            var annotations = [];
            for(var i = 0; i < 10; i++) {
                var pin = Titanium.Map.createAnnotation({
                    latitude : e.latitude-i,
                    longitude : e.longitude-i,
                    animate : true,
                    pincolor : Titanium.Map.ANNOTATION_RED,
                    rightButton : Titanium.UI.iPhone.SystemButton.DISCLOSURE//'rightButton.png'
                });
                annotations[i] = pin;
                // suppose mapView is your map object
                mapview.addAnnotation(annotations[i]);
            }
            var region = {
                latitude : e.latitude,
                longitude : e.longitude,
                animate : true,
                latitudeDelta : 0.15,
                longitudeDelta : 0.15
            };
            mapview.setLocation(region);
            Ti.API.info(e);
        });
    });
var detailWindow = Ti.UI.createWindow({
    backgroundColor : "#fff",
    navBarHidden : true,
    backgroundImage : 'screen.png'
});
var detailTitle = Ti.UI.createLabel({
    color : '#EC6512',
    font : {
        fontSize : 18,
        fontWeight : 'bold',
        fontFamily : 'Arial'
    },
    left : 12,
    top : 60,
    height : 80,
    width : 300,
    clickName : 'detailTitle',
});
detailWindow.add(detailTitle);

I should add the text to the detailTitle label in the rightButtonEvent.

rightButton event:

mapview.addEventListener('click', function(evt) {
    if(evt.clicksource == 'rightButton') {
        Titanium.API.info('Right button clicked');
        navGroup.open(detailWindow);
    };
});

I need to create a label and send a data to display in the label.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

相思碎 2024-12-28 10:06:51

要将数据存储在引脚中,您可以在循环中执行此操作,设置一个新属性(例如注释中的数据),然后在其中设置数据数组:{ title, subTitle,...}

for(var i = 0; i < 10; i++) 
{
    var pin = Titanium.Map.createAnnotation({
        latitude : e.latitude-i,
        longitude : e.longitude-i,
    data:data
        animate : true,
        pincolor : Titanium.Map.ANNOTATION_RED,
        rightButton : Titanium.UI.iPhone.SystemButton.DISCLOSURE//'rightButton.png'
    });
    annotations[i] = pin;
    // suppose mapView is your map object
    mapview.addAnnotation(annotations[i]);
}

要在点击事件中访问此数据并将其传递到您的窗口:

mapview.addEventListener('click', function(evt) {
    if(evt.clicksource == 'rightButton') {
        Titanium.API.info('Right button clicked');
        var data = evt.annotation.data;
        detailWindow.data = data;
        navGroup.open(detailWindow);
    };
});

To store data in the pin you can do this in your loop, set a new property say data in annotation, and set your data array there say : { title, subTitle,...}

for(var i = 0; i < 10; i++) 
{
    var pin = Titanium.Map.createAnnotation({
        latitude : e.latitude-i,
        longitude : e.longitude-i,
    data:data
        animate : true,
        pincolor : Titanium.Map.ANNOTATION_RED,
        rightButton : Titanium.UI.iPhone.SystemButton.DISCLOSURE//'rightButton.png'
    });
    annotations[i] = pin;
    // suppose mapView is your map object
    mapview.addAnnotation(annotations[i]);
}

To acces this data in click event and similarly pass it to your window:

mapview.addEventListener('click', function(evt) {
    if(evt.clicksource == 'rightButton') {
        Titanium.API.info('Right button clicked');
        var data = evt.annotation.data;
        detailWindow.data = data;
        navGroup.open(detailWindow);
    };
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文