标签: cllocationcoordinate2d

CLLocationCooperative2D 无法实例化

我正在尝试根据从文件中读取的数据创建一些“CLLocation”。第一步是实例化一个“CLLocationCooperative2D”,将其输入到 CLLocation 的初始化程序中。我正在 Playground 中尝试我的想法,这个非常简单的代码会生成一个运行时错误:

import CoreLocation

let lat = 48.8
let lon = -122.3
let point2D = CLLocationCoordinate2D(latitude: lat, longitude: lon)
Run Code Online (Sandbox Code Playgroud)

错误信息是

error: Execution was interrupted, reason: signal SIGABRT.
The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.
Run Code Online (Sandbox Code Playgroud)

我对 Swift 编程还很陌生,我不知道如何处理这些。例如,我如何“使用“thread return -x””来做任何事情谁能告诉我这里发生了什么?

我尝试附上整个游乐场的照片,但不知道是否可行

runtime core-location cllocationcoordinate2d swift

5
推荐指数
2
解决办法
781
查看次数

CLLocationCooperative2D 放入一个数组

我在地图套件上绘制了动态数量的位置。我很好奇如何将当前的纬度和经度放入单个数组中,因为它们当前被打印为单独的对象,而没有像应有的那样绘制地图。我知道问题所在,但不知道如何解决。这是我当前生成坐标的代码 -

  do {
        let place = try myContext.executeFetchRequest(fetchRequest) as! [Places]

        for coords in place{
            let latarray = Double(coords.latitude!)
            let lonarray = Double(coords.longitude!)
            let arraytitles = coords.title!

            let destination:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latarray, lonarray)

        print(destination)

    } catch let error as NSError {
        // failure
        print("Fetch failed: \(error.localizedDescription)")
    }
Run Code Online (Sandbox Code Playgroud)

这是控制台中的打印 - 输出

我需要什么才能使打印看起来正常工作 -所需的输出

我希望你明白我的意思。我非常感谢任何帮助!感谢您的阅读。

dictionary coordinates mapkit cllocationcoordinate2d swift

4
推荐指数
1
解决办法
3622
查看次数

Swift:如何使用CLLocationCoordinate2D将坐标存储为字符串或int?

到目前为止,这是我的代码.我正在尝试将locValue.latitude和locValue.longitude的值存储为字符串或整数.我已经尝试在方法中定义返回类型( - > String等)但是我得到一个错误,说明didChangeAuthorizationStatus方法与协议CLLocationManagerDelegate中的可选需求方法locationManager冲突.

func locationManager(manager: CLLocationManager, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
    if status == .AuthorizedAlways {
        let locValue:CLLocationCoordinate2D = manager.location!.coordinate
        self.dispLocation.text = "locations = \(locValue.latitude) \(locValue.longitude)"
    }
}
Run Code Online (Sandbox Code Playgroud)

ios cllocationcoordinate2d swift ios9 swift2

4
推荐指数
1
解决办法
8702
查看次数

从Calendar事件(EKCalendarItem/EKEvent)中检索位置lat/long(CLLocationCoordinate2d)

EKCalendarItem有属性"位置",但它是一个NSString.新的iOS8功能显示了一个很好的事件地图,所以必须CLLocationCoordinate2D附加一个EKCalendarItem,正确的?我在哪里可以找到这个CLLocationCoordinate2D

location calendar ekevent cllocationcoordinate2d ios8

2
推荐指数
1
解决办法
1268
查看次数

将CLLocationCoordinate2D转换为double或int swift

我如何将CLLocationcoordiante转换为double,以便我可以对它进行算术运算并使用它们的大小来比较坐标?在(迅速为ios)

int type-conversion cllocationcoordinate2d swift

2
推荐指数
1
解决办法
5077
查看次数

如何修复:无法指定'CLLocationDegrees'类型的值(也称为'Double')来键入'Float!' 在Swift 3中

我从谷歌地图得到一个坐标,我想将它分配给一个浮点变量,但它显示了这个错误:

无法指定"CLLocationDegrees"类型的值(也称为"Double")来键入"Float!"

func markerButtonClicked(sender:MapButton) {
 let coord = self.getCenterCoordinate()
    let addressObj = Address()
    addressObj.latitude  = coord.latitude 
    addressObj.longitude = coord.longitude
}
func getCenterCoordinate() -> (CLLocationCoordinate2D) {
    let location = CGPoint(x:self.mView.bounds.size.width/2,y:self.mView.bounds.size.height/2)
    let coord = self.mView.projection .coordinate(for: location)
    return coord
}    

class Address: NSObject {
    var latitude:Float!
    var longitude:Float!
}
Run Code Online (Sandbox Code Playgroud)

location coordinate ios cllocationcoordinate2d swift

2
推荐指数
1
解决办法
3426
查看次数

NSValue到Swift中的CLLocationCoordinate2D

我正在使用Contentful.com我的iOS应用程序作为内容后端.geo-point在我的Swift项目中,我不能让他们回到我身边.

Contentful文档说他们的API回报是" NSData与" CLLocationCoordinate2D struct.

NSValue在我的项目中接近这个,但我无法让它正常工作.这是我的代码:

var locationCoord:CLLocationCoordinate2D = CLLocationCoordinate2D(latitude: 0,longitude: 0)

var locationData:NSData = entry.fields["location"] as NSData

var locationValue:NSValue = NSValue(bytes: locationData.bytes, objCType: "CLLocationCoordinate2D")

locationCoord = locationValue.MKCoordinateValue
Run Code Online (Sandbox Code Playgroud)

然而,locationCoord.latitudelocationCoord.longitude return错误值(他们总是被一个0.0).

有人能告诉我这里我做错了什么,以及如何正常工作?谢谢.

nsvalue cllocationcoordinate2d swift ios8

1
推荐指数
1
解决办法
2201
查看次数

将CLLocationCoordinate2D转换为PFGeoPoint?

我使用CLLocationCoordinate2D获取用户的当前位置,然后将其用于Parse的nearGeoPoint.

我知道我可以简单地使用geoPointForCurrentLocationInBackground但我宁愿用CLLocationCoordinate2D检索.

objective-c ios parse-platform geopoints cllocationcoordinate2d

1
推荐指数
1
解决办法
772
查看次数

使用未解析的标识符 'CLLocationCoordinate2D'

尝试构建我的数据时,我不断收到 Use of unresolved identifier 'CLLocationCoordinate2D' 。这是一个保存数据的类,它附加了一个我稍后将在 Map 和 TableViewController 中使用的数组。关于为什么我收到此错误的任何想法?

导入基础导入 UIKit 导入 CoreData

class StationsData: NSObject {
    //define the varibles
    init () {

    }
    var stations: [StationItem]


    //initiate the array and assig the values to the array
        required init(coder aDecoder: NSCoder) {

            stations = [StationItem]()

            let row0 = StationItem(title: "Station1", address: "25 Israel Eldad St, Jerusalem", coordinate: CLLocationCoordinate2D(latitude: 31.7513239, longitude: 35.224822899999936))
            stations.append(row0)

            let row1 = StationItem(title: "Station2", address: "25 Israel Eldad St, Jerusalem", coordinate: CLLocationCoordinate2D(latitude: 0.0, longitude: 0.0)) …
Run Code Online (Sandbox Code Playgroud)

cllocationcoordinate2d swift2

1
推荐指数
1
解决办法
2264
查看次数

如何从坐标中获取地址

我想从坐标中获取地址。我在下面附上了我的代码..

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
    let lastLocation = locations.last!
    let latvalue     = lastLocation.coordinate.latitude
    let lngvalue     = lastLocation.coordinate.longitude
    self.db_latvalue = latvalue
    self.db_lngvalue = lngvalue
    let location = CLLocation(latitude: latvalue, longitude:lngvalue)
    let address = CLGeocoder.init()
    address.reverseGeocodeLocation(CLLocation.init(latitude: latvalue, longitude:lngvalue)) { (places, error) in
        if error == nil{
            if let place = places{
                   print("addressshowingssq \(place)")
                self.db_address = "\(place)"

            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

输出:

[L-30 2nd A Main Road, L-30 2nd A Main Road, HSR Layout, Bengaluru, Karnataka 560102, India @ <+12.91597974,+77.62879254> …

cllocation ios cllocationcoordinate2d swift

1
推荐指数
1
解决办法
1521
查看次数

tableview按距离swift排序

我构建了一个视图混合与地图视图和表视图,我希望我可以按距离用户位置排序单元格,我尝试使用distanceFromLoaction方法,但它显示CLLocationCoordinate没有成员distanceFromLocaiton,还有另一种方法可以做它还是修好了?

这是我的数组结构

import UIKit
import MapKit

class tripSpot: NSObject, MKAnnotation{
var title: String?
var coordinate: CLLocationCoordinate2D
var regionRadius: Double
var location: String?
var type: String?


init(title:String , coordinate: CLLocationCoordinate2D , regionRadius: Double, location: String, type: String ){
    self.title = title
    self.coordinate = coordinate
    self.regionRadius = regionRadius
    self.location = location
    self.type = type
  }

  }
Run Code Online (Sandbox Code Playgroud)

和我的tableviewcode

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("MapCell") as! mapTableViewCell

    self.tripspot.sort({ $0.coordinate.distanceFromLoaction(self.coordinate) < $1.coordinate.distanceInKilometersTo(self.coordinate)})
    if  searchController.active{
    cell.title.text = searchResults[indexPath.row].title
    cell.location.text …
Run Code Online (Sandbox Code Playgroud)

sorting distance mapkit cllocationcoordinate2d swift

0
推荐指数
1
解决办法
2031
查看次数