---
title: "UIMapView显示locationView"
author: "mmdev"
date: "2010-12-15T20:38:00Z"
tags: []
slug: "uimapview-locationview"
draft: false
lastmod: "2011-12-10T16:46:17Z"
id: 1302600
url: "https://mmdev.iteye.com/blog/1302600"
---

当属性设为TRUE时，就会显示用户当前位置。 当位置发生变化的时候，如何通知mapview更新位置呢？有两种方法

第一种：

CLLocationManager

第二种：

\[self.mapView.userLocation addObserver:self forKeyPath:@"location" options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) context:NULL];

\- (void)observeValueForKeyPath:(NSString \*)keyPath ofObject:(id)object change:(NSDictionary \*)change context:(void \*)context {

if (\[keyPath isEqualToString:@"location"]) {

//do yourself here

｝