Ios 要永久保存地图上的东西吗?

Ios 要永久保存地图上的东西吗?,ios,xcode,swift,parse-platform,Ios,Xcode,Swift,Parse Platform,我想了解一下PFGeoPoint课程。我在Parse网站上读到了这个问题,但我得到了一个似乎并没有答案的问题。 我需要保存PFGeoPoint,让所有使用我的应用程序的用户都能看到它,我真的不知道为什么。能PFGeoPoint做到吗 我的应用程序非常简单:你可以登录(PFUser)并在地图上标出一个小喷泉的位置(供正在寻找喷泉的人使用)。我想让所有的喷泉(由所有用户)对所有其他用户都可见,除非我从解析中删除它 @IBAction func changed(sender: UISegmentedC

我想了解一下
PFGeoPoint
课程。我在Parse网站上读到了这个问题,但我得到了一个似乎并没有答案的问题。 我需要保存
PFGeoPoint
,让所有使用我的应用程序的用户都能看到它,我真的不知道为什么。能
PFGeoPoint
做到吗

我的应用程序非常简单:你可以登录(
PFUser
)并在地图上标出一个小喷泉的位置(供正在寻找喷泉的人使用)。我想让所有的喷泉(由所有用户)对所有其他用户都可见,除非我从解析中删除它

@IBAction func changed(sender: UISegmentedControl) {

    switch rateFountain.selectedSegmentIndex
    {
        case 0:
            voto.text = "Good";
            break;
        case 1:
            voto.text = "Bad";
            break;
        default:
            voto.text = "Good";
            break;

    }
}

@IBAction func logout(sender: UIButton) {

    PFUser.logOut()
     print("Log Out Done")
     self.performSegueWithIdentifier("gotoLogin", sender: self)
}
@IBOutlet weak var map: MKMapView!

@IBAction func addFountain(sender: UIButton) {

    let ObFountain = PFObject(className: "Fountain")

    ObFountain["nome"] = nome.text
    ObFountain["voto"] = voto.text

    let fountain = MKPointAnnotation()
    fountain.coordinate = posizioneUtente
    fountain.title = nome.text
    fountain.subtitle = voto.text
    self.map.addAnnotation(fountain)


}
var MapViewLocationManager:CLLocationManager! = CLLocationManager()
var managerPosizione: CLLocationManager! //gestisce oggetti LocationManager
var posizioneUtente: CLLocationCoordinate2D!//coordinate



override func viewDidLoad() {
    super.viewDidLoad()

    managerPosizione = CLLocationManager() //inizializzo il locationManager che recupera la posizione utente
    managerPosizione.delegate = self
    managerPosizione.desiredAccuracy = kCLLocationAccuracyNearestTenMeters //setto l'accuratezza della nostra posizione con un errore di non oltre dieci metri
    managerPosizione.requestAlwaysAuthorization() // richiede da parte dell'utente utilizzatore l'attivazione delle funzioni di geolocalizzazione
    managerPosizione.startUpdatingLocation() // tiene traccia del cambiamento di posizione
        // Do any additional setup after loading the view.

}

func viewDidApperar(animated : Bool){
       }
//avvisa il delegate che le coordinate dell'utente sono state aggiornate
func mapView(mapView: MKMapView, didUpdateUserLocation userLocation: MKUserLocation) {
    posizioneUtente = userLocation.coordinate //salvo le coordinate dell'utente nella variabile

    print("posizione aggiornata - lat: \(userLocation.coordinate.latitude) long: \(userLocation.coordinate.longitude)")

    let span = MKCoordinateSpanMake(0.05, 0.05) // estensione dell'area da visualizzare

    let region = MKCoordinateRegion(center: posizioneUtente, span: span) // calcola le coordinate della regione

    mapView.setRegion(region, animated: true) //aggiorna la mapView
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {

    //se l'annotation è la posizione dell'Utente allora esci dalla funzione e mostra il punto blu
    if annotation is MKUserLocation {
        return nil
    }

    //creo un id da associare ad ogni annotationView
    let reuseId = "punto"
    //se esistono troppi punti nella mappa, prende quello non visto e lo riutilizza nella porzione di mappa vista
    var puntoView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)

    //se non è stata ancora creata un'AnnotationView la crea
    if puntoView == nil {
        //creo un pin di tipo MKAnnotationView che rappresenta l'oggetto reale da inserire in mappa
        puntoView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
        //cambio l'immagine standard del point annotation con una creata da me
        puntoView!.image = UIImage(named: "nella30.png")
        //sblocco la possibilità di cliccarlo per vedere i dettagli
        puntoView!.canShowCallout = true
    }
    else {
        //se esiste lo modifico con il nuovo point richiesto
        puntoView!.annotation = annotation
    }
    //restituisce un pointAnnotation nuovo o modificato
    return puntoView
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?){
    view.endEditing(true)
    super.touchesBegan(touches, withEvent: event)

}
@iAction func已更改(发件人:UISegmentedControl){
切换速率Fountain.selectedSegmentIndex
{
案例0:
voto.text=“好”;
打破
案例1:
voto.text=“坏”;
打破
违约:
voto.text=“好”;
打破
}
}
@iAction func注销(发件人:UIButton){
PFUser.logOut()
打印(“注销完成”)
self.performsguewithidentifier(“gotoLogin”,发送方:self)
}
@ibvar映射:MKMapView!
@iAction func addFountain(发送方:UIButton){
让ObFountain=PFObject(类名:“Fountain”)
ObFountain[“nome”]=nome.text
ObFountain[“voto”]=voto.text
让fountain=MKPointAnnotation()
fountain.coordinate=posizioneute
fountain.title=nome.text
fountain.subtitle=voto.text
self.map.addAnnotation(喷泉)
}
var MapViewLocationManager:CLLocationManager!=CLLocationManager()
var managerPosizione:CLLocationManager//Gestice oggetti位置经理
var Posizionette:CLLocationCoordinate2D//坐标
重写func viewDidLoad(){
super.viewDidLoad()
managerPosizione=CLLocationManager()//位置管理器
managerPosizione.delegate=self
managerPosizione.desiredAccuracy=KCallocationAccuracyNearesttenmeters//设置为“在非电压测量中发生错误时的准确度”
managerPosizione.requestAlwaysAuthorization()///richiede da parte dell'Utene utilizatore l'attivazione delle funzioni di GeoLocalizazione
managerPosizione.startUpdatingLocation()///tiene traccia del cambiamento di posizione
//加载视图后执行任何其他设置。
}
func viewDidApperar(动画:Bool){
}
//avvisa代表协调州议会
func映射视图(映射视图:MKMapView,didUpdateUserLocation用户位置:MKUserLocation){
posizioneute=userLocation.coordinate//salvo le coordinate dell'utene nella variabile
打印(“posizione aggiornata-lat:\(userLocation.coordinate.lation)long:\(userLocation.coordinate.longitude)”)
设span=MKCoordinateSpanMake(0.05,0.05)//Estension dell'area da Visualizare
let region=MKCoordinateRegion(中心:posizionette,span:span)//calcola le coordinate della regione
setRegion(区域,动画:true)//aggiorna la mapView
}
重写函数didReceiveMemoryWarning(){
超级。我收到了记忆警告()
//处置所有可以重新创建的资源。
}
func mapView(mapView:MKMapView,viewForAnnotation注释:MKAnnotation)->MKAnnotationView?{
//阿洛拉·埃斯西·达拉·福齐安·莫斯特拉·普托·布鲁的作品
如果注释是MKUserLocation{
归零
}
//creo un id da associare ad ogni注释视图
让我们看看reuseId=“punto”
//在地图上的埃西斯托诺·特罗皮蓬蒂·内拉(esistono troppi punti nella)附近,地图远景中的内拉(riutilizza nella)地区的非维斯托(prende quello non visto)地区
var puntoView=mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
//这是一个非国家的创造者,他创造了一个新的世界观
如果puntoView==nil{
//在地图中,您可以看到地图中的地图
puntoView=MKAnnotationView(注释:注释,reuseIdentifier:reuseId)
//cambio l’immagine标准点注释
puntoView!.image=UIImage(名为:“nella30.png”)
//《德塔格利观景楼》在克利卡罗的可能性
puntoView!.canShowCallout=true
}
否则{
//在新墨西哥州里希斯托点附近进行改造
puntoView!.annotation=annotation
}
//restituisce un pointAnnotation nuovo modificato
返回puntoView
}
覆盖功能触摸开始(触摸:设置,withEvent事件:UIEvent?){
view.endEditing(真)
super.touchsbegind(touchs,withEvent:event)
}

我的愿望是设置喷泉时,我按下按钮与我的当前位置和评级的好或坏。并向所有使用该应用程序的用户显示。我是斯威夫特的新手,所以你可以直接帮我编写代码。我非常感谢

PFGeoPoint
绝对是您想要的。为了给您提供一些背景信息,
PFGeoPoint
本质上是包含纬度/经度坐标的iOS
CLLocation
对象的包装器

您需要处理两种情况:

  • 加载所有附近的标记(喷泉)
  • 创建/保存新标记
  • 您应该创建另一个名为
    Fountain
    的解析类,或者任何您认为最适合您的应用程序的解析类。此类将包含地质点以及您可能需要的任何其他信息。当用户创建新的
    喷泉
    对象时,指定位置和其他属性(标题、说明等),然后保存

    在地图上,您将需要查询
    喷泉
    对象,然后使用这些对象填充地图。您可能还希望将查询限制到附近的喷泉,以提高性能

    由于这是一个非常开放的问题,这里有一些示例供您参考,欢迎使用StackOverflow


    PFGeoPoint
    绝对是您想要的。T