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

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

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

問(wèn)題描述

限時(shí)送ChatGPT賬號(hào)..

(使用 iOS 5 和 Xcode 4.2)

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

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

從表面上看,實(shí)現(xiàn) mapView:viewForAnnotation: 地圖視圖委托方法,并為用戶位置添加自定義 MKAnnotationView,將是一個(gè)完美的解決方案.它看起來(lái)像這樣:

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;
    }
}

但是,當(dāng)您放大和縮小地圖時(shí),地圖上的注釋不會(huì)按比例縮放.

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

所以我嘗試使用 MKCircle 類并將其坐標(biāo)設(shè)置為來(lái)自我的 locationManger/map 視圖委托的最新坐標(biāo).但是作為 坐標(biāo)屬性MKCircle 是只讀的,我必須刪除覆蓋,然后在每次用戶移動(dòng)時(shí)添加一個(gè)新的.發(fā)生時(shí)會(huì)引起明顯的閃爍.

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.

當(dāng)?shù)貓D視圖被放大和縮小時(shí),有什么方法可以使注釋無(wú)縫地縮放?或者有沒(méi)有一種好方法可以讓疊加層隨著用戶位置的變化無(wú)縫移動(dòng)?

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 可以通過(guò)將 MKUserLocationAnnotation 存儲(chǔ)為屬性來(lái)獲得.然后,要實(shí)際繪制圓圈,請(qǐng)將其放入地圖視圖的委托中:

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;
}

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

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

相關(guān)文檔推薦

Using Instruments to test an iOS app without having source code to the application(在沒(méi)有應(yīng)用程序源代碼的情況下使用 Instruments 測(cè)試 iOS 應(yīng)用程序)
KIF: How to auto-run/stress test an iOS app to find the cause of a rare UI bug?(KIF:如何自動(dòng)運(yùn)行/壓力測(cè)試 iOS 應(yīng)用程序以找出罕見(jiàn) UI 錯(cuò)誤的原因?)
Can#39;t change target membership visibility in Xcode 4.5(無(wú)法更改 Xcode 4.5 中的目標(biāo)成員身份可見(jiàn)性)
UITableView: Handle cell selection in a mixed cell table view static and dynamic cells(UITableView:在混合單元格表視圖靜態(tài)和動(dòng)態(tài)單元格中處理單元格選擇)
How to remove Address Bar in Safari in iOS?(如何在 iOS 中刪除 Safari 中的地址欄?)
iOS 5 SDK is gone after upgrade to Xcode 4.5(升級(jí)到 Xcode 4.5 后,iOS 5 SDK 消失了)
主站蜘蛛池模板: 91精品国产欧美一区二区成人 | 久久精品欧美电影 | 精品美女久久久久久免费 | 人人玩人人添人人澡欧美 | 国产精品久久片 | 午夜精品久久久久久久久久久久久 | 亚洲在线视频 | 精品免费视频 | 97碰碰碰| 免费一区| 91欧美精品成人综合在线观看 | 99pao成人国产永久免费视频 | 久久久久久国 | 蜜臀久久99精品久久久久久宅男 | 欧美精品一区二区三区视频 | 少妇午夜一级艳片欧美精品 | 久久一久久 | 国产成人精品久久二区二区91 | 黄色网络在线观看 | 热久久免费视频 | 亚洲精选一区二区 | 国产精品久久久久久久久 | av永久| 国产精品久久久久久久久久三级 | 欧美一区二区在线免费观看 | 国产欧美性成人精品午夜 | 久久久久久久夜 | 狠狠干网站 | 午夜视频在线播放 | jizz亚洲人| 精品国产乱码久久久久久图片 | 黄色片网站在线观看 | 伊人久麻豆社区 | 一区二区三区四区不卡 | 91在线最新| 国产精品久久久久久中文字 | 精品婷婷| 97精品国产97久久久久久免费 | 中文字幕成人av | 婷婷成人在线 | 国产精品激情小视频 |