Продолжая мой предыдущий решенный вопрос Я столкнулся с новой проблемой, поэтому я начал новый вопрос.
Я пытаюсь добавить круг для каждого CLLocationCoordinates2D в массиве var routeObsticle: [CLLocationCoordinate2D] = []
и у меня есть счетчик var routeObsticlePosition = 0
, который внутри функции используется для обхода позиций массива, чтобы получить значение.Массив получает свои значения, добавленные в функцию checkAlerts()
func checkAlerts() {
// MARK: checking if any notification is on our route
while trackingCoordinatesArrayPosition != ( (trackingCoordinatesArray.count) - 1) {
let trackingLatitude = trackingCoordinatesArray[trackingCoordinatesArrayPosition].latitude
let trackingLongitude = trackingCoordinatesArray[trackingCoordinatesArrayPosition].longitude
let alertLatitude = alertNotificationArray[alertNotificationArrayPosition].latitude
let alertLongitude = alertNotificationArray[alertNotificationArrayPosition].longitude
let coordinateFrom = CLLocation(latitude: trackingLatitude, longitude: trackingLongitude)
let coordinateTo = CLLocation(latitude: alertLatitude, longitude: alertLongitude)
let coordinatesDistanceInMeters = coordinateFrom.distance(from: coordinateTo)
// if trackingLatitude == alertLatitude && trackingLongitude == alertLongitude {
if coordinatesDistanceInMeters <= 10 {
print( "found problem")
routeObsticle.append(alertNotificationArray[alertNotificationArrayPosition])
trackingCoordinatesArrayPosition = ( trackingCoordinatesArrayPosition + 1)
}
else if alertNotificationArrayPosition < ((alertNotificationArray.count) - 1) {
alertNotificationArrayPosition = alertNotificationArrayPosition + 1
}
else if alertNotificationArrayPosition == (alertNotificationArray.count - 1) {
trackingCoordinatesArrayPosition = ( trackingCoordinatesArrayPosition + 1)
alertNotificationArrayPosition = 0
}
}
}
Но я не могу нарисовать круг для каждой записи массива.
Вот функция:
func displayObsticles() {
while routeObsticlePosition <= ((routeObsticle.count) - 1) {
let obsticleLatitude = routeObsticle[routeObsticlePosition].latitude
let obsticleLongitude = routeObsticle[routeObsticlePosition].longitude
let title = ""
let circleCoordinates = CLLocationCoordinate2DMake(obsticleLatitude, obsticleLongitude)
let regionRadious = 10.0
// let region = CLCircularRegion(center: CLLocationCoordinate2D(latitude: obsticleLatitude, longitude: obsticleLatitude), radius: regionRadious, identifier: title)
let circle = MKCircle(center: (routeObsticle[routeObsticlePosition]), radius: regionRadious)
mapView.add(circle)
routeObsticlePosition = ((routeObsticlePosition) + 1)
}
if routeObsticlePosition == ((routeObsticle.count) - 1) {
return
}
}
тогда у меня есть метод MKCircleRenderer:
func mapView(mapView: MKMapView, rendererForOverlay overlay: MKOverlay) -> MKOverlayRenderer{
let circleRenderer = MKCircleRenderer(overlay: overlay)
circleRenderer.strokeColor = UIColor.red
circleRenderer.lineWidth = 1.0
return circleRenderer
}
Вот консольные сообщения:
2018-05-15 15:45:01.056042+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10554.25436.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.056198+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10555.25436.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.056318+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10552.25436.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.056429+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10553.25436.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.056561+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10551.25436.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.056698+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10555.25434.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.056843+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10555.25435.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.056977+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10554.25435.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.057120+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10553.25435.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.057257+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10552.25435.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.057391+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10551.25435.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.057531+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10555.25432.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.057643+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10555.25433.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.057772+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10554.25430.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.057987+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10555.25430.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.058244+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10555.25431.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.058450+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10552.25430.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.058685+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10553.25430.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.058939+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10551.25430.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.059208+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10555.25429.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.059478+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10554.25429.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.059718+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10553.25429.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.059979+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10552.25429.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:01.060211+0200 fix-it mapView[3541:172723] [VKDefault] Tile 10551.25429.16 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:02.424614+0200 fix-it mapView[3541:172723] [VKDefault] Tile 42214.101729.18 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:02.424753+0200 fix-it mapView[3541:172723] [VKDefault] Tile 42213.101729.18 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:02.424899+0200 fix-it mapView[3541:172723] [VKDefault] Tile 42212.101729.18 (128) in current unloaded state for 0.00 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (0.00 sec)
2018-05-15 15:45:12.513053+0200 fix-it mapView[3541:172723] [VKDefault] Tile 42214.101729.18 (128) in current unloaded state for 10.09 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (10.09 sec)
2018-05-15 15:45:12.513209+0200 fix-it mapView[3541:172723] [VKDefault] Tile 42213.101729.18 (128) in current unloaded state for 10.09 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (10.09 sec)
2018-05-15 15:45:12.513319+0200 fix-it mapView[3541:172723] [VKDefault] Tile 42212.101729.18 (128) in current unloaded state for 10.09 seconds - Raster Overlays Above Labels - Failed to decode (terminal) (10.09 sec)
Можно ли рисовать несколько кругов следующим образом или как мне подойти к задаче?Спасибо заранее.Я начинаю с оверлеев и наверняка что-то неправильно понял.