久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 MKMapView 中圍繞用戶位置畫一個半徑為 1000m 的

Draw a circle of 1000m radius around users location in MKMapView(在 MKMapView 中圍繞用戶位置畫一個半徑為 1000m 的圓)
本文介紹了在 MKMapView 中圍繞用戶位置畫一個半徑為 1000m 的圓的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

(使用 iOS 5 和 Xcode 4.2)

我有一個 MKMapView,想在用戶位置周圍畫一個半徑為 1000m 的圓.

I have an MKMapView and want to draw a circle of 1000m radius around the user location.

從表面上看,實現 mapView:viewForAnnotation: 地圖視圖委托方法,并為用戶位置添加自定義 MKAnnotationView,將是一個完美的解決方案.它看起來像這樣:

On the surface it would seem that implementing the mapView:viewForAnnotation: map view delegate method, and adding a custom MKAnnotationView for the users location, would be a perfect solution. It would look something like this:

- (MKAnnotationView *)mapView:(MKMapView *)mapView
            viewForAnnotation:(id <MKAnnotation>)annotation
{
    // If it's the user location, return my custom MKAnnotationView.
    if ([annotation isKindOfClass:[MKUserLocation class]]) {
        return myCustomAnnotationView;
    } else {
        return nil;
    }
}

但是,當您放大和縮小地圖時,地圖上的注釋不會按比例縮放.

However annotations on the map don't scale when you zoom in and out of the map.

所以我嘗試使用 MKCircle 類并將其坐標設置為來自我的 locationManger/map 視圖委托的最新坐標.但是作為 坐標屬性MKCircle 是只讀的,我必須刪除覆蓋,然后在每次用戶移動時添加一個新的.發生時會引起明顯的閃爍.

So I tried adding an overlay (because overlays scale with the map), using the MKCircle class and setting its co-ordinates to the latest co-ordinates from my locationManger/map view delegate. However as the coordinate property of MKCircle is readonly, I'm having to remove the overlay then add a new one each time the user moves. Causing a noticeable flicker as it happens.

當地圖視圖被放大和縮小時,有什么方法可以使注釋無縫地縮放?或者有沒有一種好方法可以讓疊加層隨著用戶位置的變化無縫移動?

Is there any way to make an annotation scale seamlessly as the map view is scaled in and out? Or is there a good way to make an overlay move seamlessly with changes in the users location?

非常感謝您的幫助:)

推薦答案

嘗試自定義疊加層.在 viewDidLoad 中添加:

Try a custom overlay. Add this in viewDidLoad:

MKCircle *circle = [MKCircle circleWithCenterCoordinate:userLocation.coordinate radius:1000];
[map addOverlay:circle];

userLocation 可以通過將 MKUserLocationAnnotation 存儲為屬性來獲得.然后,要實際繪制圓圈,請將其放入地圖視圖的委托中:

userLocation can be obtained by storing the MKUserLocationAnnotation as a property. Then, to actually draw the circle, put this in the map view's delegate:

- (MKOverlayRenderer *)mapView:(MKMapView *)map viewForOverlay:(id <MKOverlay>)overlay
{
    MKCircleRenderer *circleView = [[MKCircleRenderer alloc] initWithOverlay:overlay];
    circleView.strokeColor = [UIColor redColor];
    circleView.fillColor = [[UIColor redColor] colorWithAlphaComponent:0.4];
    return circleView;
}

這篇關于在 MKMapView 中圍繞用戶位置畫一個半徑為 1000m 的圓的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Using Instruments to test an iOS app without having source code to the application(在沒有應用程序源代碼的情況下使用 Instruments 測試 iOS 應用程序)
KIF: How to auto-run/stress test an iOS app to find the cause of a rare UI bug?(KIF:如何自動運行/壓力測試 iOS 應用程序以找出罕見 UI 錯誤的原因?)
Can#39;t change target membership visibility in Xcode 4.5(無法更改 Xcode 4.5 中的目標成員身份可見性)
UITableView: Handle cell selection in a mixed cell table view static and dynamic cells(UITableView:在混合單元格表視圖靜態和動態單元格中處理單元格選擇)
How to remove Address Bar in Safari in iOS?(如何在 iOS 中刪除 Safari 中的地址欄?)
iOS 5 SDK is gone after upgrade to Xcode 4.5(升級到 Xcode 4.5 后,iOS 5 SDK 消失了)
主站蜘蛛池模板: 久久这里只有精品首页 | 日本一级淫片免费啪啪3 | 日本黄色激情视频 | 精品国产亚洲一区二区三区大结局 | 日本黄色大片免费 | 亚洲免费久久久 | 日韩国产欧美一区 | 亚洲成人免费视频在线 | 国产精品激情在线 | 日韩精品成人一区二区三区视频 | 亚洲成人黄色 | 一级特黄视频 | 国产免费看 | 91久久精品一区二区二区 | 中文久久 | 久久久久久九九九九九九 | 欧美国产精品一区二区三区 | 中文字幕亚洲区一区二 | 我要看黄色录像一级片 | 激情 婷婷| 天天插天天操 | 国产日韩欧美在线一区 | 精品视频一区二区三区在线观看 | 黄色一级网 | 日本三级在线视频 | 日本不卡一区二区三区 | 欧美一级二级在线观看 | 欧美午夜剧场 | 中国美女撒尿txxxxx视频 | 精品欧美| 成人午夜在线 | 午夜精品一区二区三区在线视 | 欧美日韩在线一区 | www久久久 | 成人黄色电影免费 | 久草免费在线视频 | 亚洲黄色av网站 | 精品一区精品二区 | 99精品一级欧美片免费播放 | 色在线看 | 国产精品视频在线观看 |