这是我的代码分为合金/JS/造型无论我在哪里放置borderRadius/borderWidth
属性,它都会忽略它
合金:
<Label id="image_label"></Label>
.JS:
function setAnnotation(location) {
var annotation = map.createAnnotation({
title: location.title,
subtitle: location.latitude + ', ' + location.longitude,
latitude: location.latitude,
longitude: location.longitude,
image: $.image_label.toImage(),
borderRadius:22, //DOESNT WORK
borderWidth: 6, //DOESNT WORK
});
$.map.setAnnotations([annotation]);
}
风格:
//LABEL ANNOTATION
"#image_label": {
color : 'black',
font : {fontSize:'15dp',font:"monospace",fontWeight:"bold"},
height : '30dp',
width : '30dp',
borderRadius:999, //DOESNT WORK
borderWidth: 99, //DOESNT WORK
backgroundImage:'https://pbs.twimg.com/profile_images/604644048/sign051.gif'
}
最好的方法是创建一个视图和一个标签,并将borderRadius/borderWidth/backgroundImage添加到视图中,然后在最后将view.toImage((分配给注释。请记住,注释本身没有 borderRadius/borderWidth 属性 (http://docs.appcelerator.com/platform/latest/#!/api/Modules.Map.Annotation(
var view = Ti.UI.createView({
width:30,
height:30,
borderRadius:15,
borderWidth: 3,
backgroundImage:'https://pbs.twimg.com/profile_images/604644048/sign051.gif'
});
var lbl = Ti.UI.createLabel({
text:"2"
});
view.add(lbl);
mapView.addAnnotation(
maps.createAnnotation({
latitude: 37.368122,
longitude: -121.913653,
title: "company",
image: view.toImage()
})
)
您也可以将其放入小部件的视图中,并用参数填充文本/图像以使用Alloy的强大功能并保持代码没有视图代码。