0
votes

Here is my code split into Alloy/JS/Styling No Matter where I place the borderRadius/borderWidth properties it ignores it

Alloy:

<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]);
}

Style:

//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'

}

1

1 Answers

2
votes

Best way would be create a View and a Label and add the borderRadius/borderWidth/backgroundImage to the View, then at the end asssign the view.toImage() to the annotation. Keep in mind that the annotation itself doesn't have the borderRadius/borderWidth property (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()
    })
)

you could also put that into the view of a widget and fill the text/image with a parameter to use the power of Alloy and keep the code free of view-code.