Titanium - 在注释中存储信息
我正在地图视图上进行多个注释,并且正在打开一个新的详细窗口以进行右键选择。我应该通过标签在详细窗口中显示一些信息,并且每个引脚注释显示的信息都不同。如何将一些数据存储到引脚注释中?帮助我完成这项工作。提前致谢。
这是我的代码.. 注释创建:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要将数据存储在引脚中,您可以在循环中执行此操作,设置一个新属性(例如注释中的数据),然后在其中设置数据数组:
{ title, subTitle,...}
要在点击事件中访问此数据并将其传递到您的窗口:
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,...}
To acces this data in click event and similarly pass it to your window: