ios - Create Map Pins from XML/Array -
i'm working on project grabs bunch of traffic-cameras xml file , and shows them in app. have got tableview , running, working (click on cell, opens detailview , shows traffic-image). however, want display cameralocations on map, users can press pin want see camera of (and sends them detailview show camera).
i'm not sure how make work, ideas?
i got longitude , latitude coordinates. link xml file: http://webkamera.vegvesen.no/metadata
it in norwegian but, lengdegrad = longitude , breddegrad = latitude.
this want achieve (photoshop screenshot): https://gyazo.com/93d885606efd6e6369018243b64d47e8
i don't know if right place ask, please if know :-)
thanks in advance
to use xml data:
add xml file project , use nsxmlparser read it.
to create annotations on map:
create annotation class based on mkannotationview, that:
class annotation: nsobject, mkannotation { var coordinate: cllocationcoordinate2d var title: string? // optionally add subtitle init(coordinate: cllocationcoordinate2d, title: string) { self.coordinate = coordinate self.title = title } }
to create , add anotations map, each of parsed items xml file create 1 annotation , add map. this, depending on format of parsed data. let's have data in array called cameras:
for camera in cameras { let coord = cllocationcoordinate2dmake(camera.latitude, camera.longitude) let annotation = annotation(coordinate: coord, title: camera.title) mapview.addannotation(annotation) }
Comments
Post a Comment