func drawLineOnMap() {
let center = self.mapView.mapCenter.position
let geopath = MSGeopath(positions:
[MSGeoposition(latitude: center.latitude-0.0005, longitude: center.longitude-0.001),
MSGeoposition(latitude: center.latitude+0.0005, longitude: center.longitude+0.001)])
let mapPolyline = MSMapPolyline()
mapPolyline.path = geopath
mapPolyline.strokeColor = UIColor.black
mapPolyline.strokeWidth = 3 // 3 marked in the example but always reverts to 1
mapPolyline.strokeDashed = true
// Add Polyline to a layer on the map control.
let linesLayer = MSMapElementLayer()
linesLayer.zIndex = 1
linesLayer.elements.add(mapPolyline)
mapView.layers.add(linesLayer);
}
Using the example from the following Microsoft article the strokeWidth cannot be overridden.
Link to article