- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我尝试使用用户当前位置创建注释。在将我的应用程序连接到 Parse 之前,我可以将信息保存到 NSUserDefaults 中,并且它工作得很好。现在我正在使用 Parse,我无法弄清楚如何在一个 View Controller 中调用在 Parse 中保存的坐标,以便我可以在不同的 map View Controller 中将坐标显示为注释。我当前使用的代码是
let userLoc = NSUserDefaults.StandardUserDefaults().dictionaryForKey("Location") as! [String : NSNumber]
Let userLat = userLoc["lat"]
Let userLng = userLoc["lng"]
var latitude:CLLocationDegrees = userLat as! CLLocationDegrees
var longitude:CLLocationDegrees = userLng as! CLLocationDegrees
那么我该如何修改这段代码才能显示我保存到 Parse 的坐标呢?谢谢
最佳答案
我认为this answer就是您要找的
代码:
//MARK: (471) Crossing Positions
//*******************************************************
let myGeoPoint = PFGeoPoint(latitude: lat, longitude:lon)
let myParseId = PFUser.currentUser().objectId //PFUser.currentUser().objectId
var radius = 100.0
println("****** this is my geoPoint from map view controller: \(myGeoPoint)")
//MARK: *** let's look for other users ***
var nearArray : [CLLocationCoordinate2D] = []
func filterByProximity() {
PFQuery(className: "Position")
.whereKey("where", nearGeoPoint: myGeoPoint, withinKilometers: radius) //(474)
.findObjectsInBackgroundWithBlock ({
objects, error in
if let proximityArray = objects as? [PFObject] {
// println("****** here the proximity matches: \(proximityArray)")
for near in proximityArray {
// println("here they are \(near)")
let position = near["where"] as? PFGeoPoint
var theirLat = position?.latitude //this is an optional
var theirLong = position?.longitude //this is an optional
var theirLocation = CLLocationCoordinate2D(latitude: theirLat!, longitude: theirLong!)
nearArray.append(theirLocation)
if nearArray.isEmpty {
println("*** ERROR! anyone close by ***")
} else
{
for person in nearArray {
let span = MKCoordinateSpanMake(2.50, 2.50)
let region = MKCoordinateRegionMake(theirLocation, span)
self.mapView.setRegion(region, animated: true)
let theirAnotation = MKPointAnnotation()
theirAnotation.setCoordinate(theirLocation)
theirAnotation.title = near["who"] as String
self.mapView.addAnnotation(theirAnotation)
}
}
}
println("****** in a radius of \(radius) there are \(nearArray.count) bikers ******")
}
})
}
filterByProximity()
关于swift - 通过从 Parse 获取数据在 MKMapKit 上显示注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31085968/
我正在尝试制作一个应用程序来查看我要去的大学,但我无法只查看一个城市。我试图确保用户无法滚动经过城市。然后我尝试覆盖该区域。我认为 setRegion 方法将有助于解决该问题,但显然不会。关于如何设置
我想确定 MKMapViewDelegate 中的最小 + 最大可见纬度和经度值委托(delegate)方法: - (void)mapView:(MKMapView *)mapView regionD
我想知道如何确保 callout 气泡不会在 MKMapView 上被取消选择。 每当我按下 map (背景)时,此 View : 转向: 这是我不想允许的。但我确实想保留对 callOutButto
似乎我为高斯模糊找到的所有东西都需要像 GPUImage 这样的图像或视频。有谁知道 GPUimage 的分支或在 MKMapKit map 区域上放置高斯模糊的方法?目标是 map 仍然可以缩放和拖
如何让我的 MKMapView 跟随我的用户直到他们滚动,然后再有一个按钮来跟随用户? 这是我希望它拥有的流程。 查看负载:放大并以用户当前位置为中心,然后跟随用户四处走动。 用户滚动:在按下按钮之前
我的应用程序上有用户位置,但如何在当前用户位置上添加注释?我是否必须获取用户位置的经度和纬度并以这种方式删除注释?或者我该怎么做? 最佳答案 首先导入必要的框架(CoreLocation 和 MapK
默认情况下,我们可以在 map View 上显示用户的位置。在点击注释图钉时,它将显示“当前位置”。但我想将用户的地址显示为街道、城市和国家。我如何使用 CLGeoCoder 类来做到这一点? 最佳答
我目前正在尝试让用户向 map 添加图钉,然后 map 将绘制一个连接这些图钉的多边形。但是我想扩展它以允许用户能够拖动图钉并且多边形将相应地更新。 MKMapView 根据它们在数组中的排列(如果我
每当我设置 MKMapKit 的区域属性时,它都会使跨度加倍。 例如: MKCoordinateRegion currentRegion = map.region; // assume the cur
大家好, 我正在尝试让 MKMapView 启动并运行,但是我似乎无法克服似乎是引用错误的问题。我花了几个小时在谷歌上搜索这个以及昨晚。 标题: #import #import @interfac
我已经被困在这个EXC_BAD_ACCESS错误2天了。我有一个reloadAnnotations方法,可以在添加新注释之前删除所有注释。在删除注释之前,此方法应检查新集合是否包含相同的位置,以便不会
我在 map 上有 2-10 个注释图钉。当我单击一个按钮时,我希望 map 缩小并居中,以便用户可以看到所有图钉。我怎样才能做到这一点? 提前致谢 最佳答案 假设您有一个包含所有注释的数组,您可以执
在代码中构建布局,一切都很好,直到我需要设置 map 区域: if let coordinate = item.location?.coordinate { let regio
我正在 iOS 中使用 Mapkit 创建一个应用程序,我真正想做的是在 map 上显示一个特定位置......暂停...... ..然后缩放到用户位置。 我的代码中有以下内容,但不知道如何应用暂停或
我制作了一个具有 map 功能的应用程序。 每当我的 Controller 打开包含 map 的屏幕时,内存使用量直接从 45mb 增加到 180MB。 我刚刚使用了一个 MKMap 并设置了它的 d
我正在尝试将一些 MKOverlays 添加到 MKMapKit。我将使用我们的 WMS 服务器根据谷歌的网格位置标准获取图 block 并添加它们。要调用电话,我需要告诉我们的 WMS 服务器谷歌图
如何获取所有可见的 MKAnnotationViews - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotati
请有人帮忙解决一个 MapView 问题。我有一个自定义注释。当用户点击注释时,我希望它向上移动屏幕然后消失。作为动画代码的测试(因为我是新手!),我尝试了以下操作: func mapView(_ m
我认为这将是相当普遍的事情 - 但无法在任何地方找到它。我知道如何将图像放在 map 上。我使用在这里找到的 CSMapAnnotation http://spitzkoff.com/craig/?p
Apple 示例代码 TileMap 很好地展示了如何使用 gdal2tiles 添加光栅图像叠加层,但这取决于设备上的 tile 目录。调整代码以从 Web 加载文件的最佳方法是什么? 我注意到它做
我是一名优秀的程序员,十分优秀!