aboutsummaryrefslogtreecommitdiff
path: root/iosApp/iosApp/Map/MapViewController.swift
diff options
context:
space:
mode:
Diffstat (limited to 'iosApp/iosApp/Map/MapViewController.swift')
-rw-r--r--iosApp/iosApp/Map/MapViewController.swift48
1 files changed, 28 insertions, 20 deletions
diff --git a/iosApp/iosApp/Map/MapViewController.swift b/iosApp/iosApp/Map/MapViewController.swift
index c7bc91d..f424389 100644
--- a/iosApp/iosApp/Map/MapViewController.swift
+++ b/iosApp/iosApp/Map/MapViewController.swift
@@ -224,14 +224,14 @@ class OurMaplyViewController: MaplyViewController {
Float(marker.latitude))
}
- let fontSize = 11.0
+ let fontSize = Constants.markerLabelTextSize
let colorReport = UIColor(red: 0.0, green: 0.5, blue: 0.0, alpha: 1.0)
let colorLabel = UIColor.darkGray
let colorLabelOutline = UIColor.white
let vectorDesc: [AnyHashable : Any] = [
kMaplyColor: colorReport,
- kMaplyVecWidth: 12.0,
+ kMaplyVecWidth: Constants.reportLineWidth,
kMaplyWideVecImpl: kMaplyWideVecImplPerf
]
@@ -248,26 +248,26 @@ class OurMaplyViewController: MaplyViewController {
screenMarker.layoutImportance = .greatestFiniteMagnitude
screenMarker.loc = MaplyCoordinateMakeWithDegrees(Float(marker.longitude),
Float(marker.latitude))
- var type: Marker.Type_ = .default_
+ var image: UIImage
if isReport {
// For reports, position, start and end icons must be different
switch i {
- case markers.startIndex: type = .reportStart
- case markers.endIndex - 1: type = .reportEnd
- default: type = .reportPosition
+ case markers.startIndex: image = getIcon(markerType: .reportStart)
+ case markers.endIndex - 1: image = getIcon(markerType: .reportEnd)
+ default: image = getIcon(forDirection: points[i], to: points[i + 1])
}
} else {
- type = marker.type
+ image = getIcon(markerType: marker.type)
}
- screenMarker.image = getIcon(markerType: type)
+ screenMarker.image = image
- var size = 50.0
+ var size = Constants.markerSize
if isReport {
// For reports, position, start and end sizes must be different
switch i {
- case markers.startIndex: size = 40.0
- case markers.endIndex - 1: size = 40.0
- default: size = 22.0
+ case markers.startIndex: size = Constants.markerSize
+ case markers.endIndex - 1: size = Constants.markerSize
+ default: size = Constants.vertexsize
}
}
screenMarker.size = CGSize(width: size, height: size)
@@ -311,14 +311,14 @@ class OurMaplyViewController: MaplyViewController {
"features": [
[
"type": "Feature",
- "properties": [],
+ "properties": [] as [Any],
"geometry": [
"type": "LineString",
"coordinates": markers.map({ marker in
[marker.longitude, marker.latitude]
})
- ]
- ]
+ ] as [String : Any]
+ ] as [String : Any]
]
]
if let vector = MaplyVectorObject(fromGeoJSONDictionary: geoJSON) {
@@ -342,14 +342,14 @@ class OurMaplyViewController: MaplyViewController {
func display(geofences: [Geofence]) {
clear(geofences: true)
- let fontSize = 11.0
+ let fontSize = Constants.geofenceLabelTextSize
let colorFill = UIColor(red: 0.10, green: 0.46, blue: 0.82, alpha: 1.00)
let colorLabel = UIColor(red: 0.10, green: 0.46, blue: 0.82, alpha: 1.00)
let colorLabelOutline = UIColor.white
let vectorDesc: [AnyHashable : Any] = [
kMaplyColor: colorFill,
- kMaplyVecWidth: 12.0,
+ kMaplyVecWidth: Constants.geofenceLineWidth,
kMaplyWideVecImpl: kMaplyWideVecImplPerf
]
@@ -375,7 +375,7 @@ class OurMaplyViewController: MaplyViewController {
"features": [
[
"type": "Feature",
- "properties": [],
+ "properties": [] as [Any],
"geometry": [
"type": "Polygon",
"coordinates": [
@@ -383,8 +383,8 @@ class OurMaplyViewController: MaplyViewController {
[coordinate.y, coordinate.x]
}
]
- ]
- ]
+ ] as [String : Any]
+ ] as [String : Any]
]
]
if let vector = MaplyVectorObject(fromGeoJSONDictionary: geoJSON) {
@@ -439,4 +439,12 @@ class OurMaplyViewController: MaplyViewController {
return UIImage(named: MarkerTransformations
.markerTypeToImageName(markerType: markerType))!
}
+
+ private func getIcon(forDirection a: MaplyCoordinate, to b: MaplyCoordinate) -> UIImage {
+ let vectorX = b.x - a.x
+ let vectorY = b.y - a.y
+ let angleRad = atan2(vectorY, vectorX)
+ return UIImage(named: MarkerTransformations
+ .angleToImageName(rad: angleRad))!
+ }
}