首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当我尝试放大时,地图保持反弹

当我尝试放大时,地图保持反弹
EN

Stack Overflow用户
提问于 2016-01-08 12:31:33
回答 1查看 261关注 0票数 0

你好,斯威夫特新手来了。我在地图应用程序上工作,我有地区跨度的问题。我将其更改为0.05,并希望将其放大和缩小。然后找出当我移动时,纬度和经度会发生变化。这使我的地图保持反弹到0.05跨度,这是我的代码。

代码语言:javascript
复制
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {

    let latispan = 0.05
    let longspan = 0.05

    let location = locations.last
    let center = CLLocationCoordinate2D(latitude: location!.coordinate.latitude, longitude: location!.coordinate.longitude)
    let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: latispan, longitudeDelta: longspan))
    self.mapView.setRegion(region, animated: true)
    //labelText.text = "\(location!.coordinate.latitude) , \(location!.coordinate.longitude)"

    labelText.text = "\(region.span.latitudeDelta), \(region.span.longitudeDelta)"
    //self.locationManager.stopUpdatingLocation()
}
func locationManager(manager: CLLocationManager, didFailWithError error: NSError) {
    print("Errors:" + error.localizedDescription)
}

我试着得到当前的跨度,这样我以后可能会改变我的纬度跨度,长跨度,但我就是找不到一种方法。

EN

Stack Overflow用户

发布于 2016-01-09 15:08:16

尝试以下操作可能会对您有所帮助:)

代码语言:javascript
复制
func loadMapData() {

        if let location = AppDelegate.getInstance().newlocation {
            let center = CLLocationCoordinate2D(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)
            let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05))
            self.map.setRegion(region, animated: true)
        }

        self.map.removeAnnotations(self.map.annotations)
        self.map.showsUserLocation = true
        for retailer in self.liststores {
            let information = MKPointAnnotation()
            information.coordinate = CLLocationCoordinate2D(latitude: retailer.retailer_lat!.doubleValue, longitude: retailer.retailer_lon!.doubleValue)
            information.title = retailer.retailer_name
            information.subtitle = retailer.retailer_addr1! + retailer.retailer_addr2!
            self.map.addAnnotation(information)
        }
    }
票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34669541

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档