Swift programming: Multiple Positions on Map View -


i have simple problem , new ios - want have multiple gps streams coming on same map. please how done

the current code works:

import uikit import mapkit import corelocation  class viewcontroller: uiviewcontroller, mkmapviewdelegate, cllocationmanagerdelegate {  @iboutlet weak var mapview: mkmapview!  let locationmanager = cllocationmanager()  override func viewdidload() {     super.viewdidload()      self.locationmanager.delegate = self     self.locationmanager.desiredaccuracy = kcllocationaccuracybest     self.locationmanager.requestwheninuseauthorization()     self.locationmanager.startupdatinglocation()     self.mapview.showsuserlocation = true     self.mapview.delegate = self }  override func didreceivememorywarning() {     super.didreceivememorywarning()     // dispose of resources can recreated. }  func locationmanager(manager: cllocationmanager, didupdatelocations locations: [cllocation]) {     let location = locations.last      let center = cllocationcoordinate2d(latitude: location!.coordinate.latitude, longitude: location!.coordinate.longitude)      let region = mkcoordinateregion(center: center, span: mkcoordinatespan(latitudedelta: 0.01, longitudedelta: 0.01))      self.mapview.setregion(region, animated: true)      self.locationmanager.stopupdatinglocation() }  func locationmanager(manager: cllocationmanager, didfailwitherror error: nserror) {     print("errors: " + error.localizeddescription) } 

}

but gives me 1 location.

you have map displayed, , on map want display 2 locations.

the first location of device, co-ordinates device's gps.

the second location else's position. getting co-ordinates from? cannot access gps. app on device must write co-ordinates server somewhere. app reads these co-ordinates server , displays them using mkpointannotation. there no "gps stream" app other device running on.

similarly, app on device must write own co-ordinates, can appear on app.

if don't have server, investigate using apple's cloudkit (for example).


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -