I have mulitple for- in loops but I'm not sure how to bounce back up to the top loop each time for the four geojson records I have that are individual arrays, place, pass and lat/long.
Code:
for aPlace in place {
print(aPlace)
for aPass in pass {
print(aPass)
for var (i, x) in zip(lat, long) {
print(i)
print(x)
//These must be in this order to load right at least from what I have seen thus far
var point = MGLPointAnnotation()
point.title = aPlace
point.subtitle = aPass
point.coordinate = CLLocationCoordinate2D(latitude: i, longitude: x)
print(point)
print(" ")
mapView.addAnnotation(point)
//after this the code jumps to pass type record2
break
}; break; continue
}
}
I have some error checking prints in the there to help me understand what is going on...
this is what I get printed out...
North Shore Trailhead
passRecord1
48.066736
-123.835361
<MGLPointAnnotation: 0x7fa9b3a37630; title = "North Shore Trailhead"; subtitle = "passRecord1"; coordinate = 48.066736, -123.835361>
Lyre RiverTrailhead
passRecord1
48.066736
-123.835361
<MGLPointAnnotation: 0x7fa9b1c2aa40; title = "Lyre RiverTrailhead"; subtitle = "passRecord1"; coordinate = 48.066736, -123.835361>
Having a different trailhead location in record 2 is what I want so that is ok. After that it just records the same passRecord# and same lat/lon which is then reported to the MGLAnnotation which is a mapbox marker.
Is there a better way to do this? I have searched for hours to find an explanation for this to no avail.
Documentation:
AppleDoc has a part on label statements but I can't seem to get that to work either.
if you look at nested loops in this link it will show what the program is doing...just don't know how to fix it...