我removeAnnotations用来删除我的注释,mapView但同样删除用户位置ann.我该如何防止这种情况,或者如何让用户回来查看?
NSArray *annotationsOnMap = mapView.annotations;
[mapView removeAnnotations:annotationsOnMap];
Run Code Online (Sandbox Code Playgroud) 是否可以将指示用户所在位置的蓝点更改为MKMapView图像?比如一辆小汽车或任何.png形象?

虽然我已经添加了
NSLocationWhenInUseUsageDescription
我一直收到这个警告
此应用尝试访问隐私敏感数据,但没有使用说明.应用程序的Info.plist必须包含一个NSLocationWhenInUseUsageDescription键,其中包含一个字符串值,向用户解释应用程序如何使用此数据
仅供参考:我在应用程序中有多个info.Plist.不知道该怎么办?
当我开始我的应用程序新鲜,或在很长一段时间后恢复,MKMapView的userLocation的概念是错误的,并显示我在海中.
我使用以下代码:
self.mapView.centerCoordinate = self.mapView.userLocation.location.coordinate;
[mapView setCenterCoordinate:self.mapView.userLocation.location.coordinate zoomLevel:ZOOM_LEVEL animated:YES];
Run Code Online (Sandbox Code Playgroud)
经过漫长的应用程序简历或全新的开始......
我正在尝试找到用户位置的纬度和经度,以便我可以在viewdidload中将地图置于用户的中心位置.
我已经实现了似乎是正确的代码,但userLat(纬度)和userLon(经度)的值是关闭的.
NB有人和我有同样的问题,但他的答案从未得到解决: Mapbox iOS8 Swift mapView.showUsersLocation
import Mapbox
class ViewController: UIViewController, MGLMapViewDelegate, CLLocationManagerDelegate {
// let locationManager = CLLocationManager()
@IBOutlet weak var mapView: MGLMapView!
override func viewDidLoad() {
super.viewDidLoad()
// Initalise map's center coordinate as vancouver
mapView.setCenterCoordinate(CLLocationCoordinate2D(latitude: 49.283382,
longitude: -123.117394),
zoomLevel: 15, animated: false)
view.addSubview(mapView)
// Set the delegate property of our map view to self after instantiating it.
mapView.delegate = self
// User location
mapView.showsUserLocation = true
let userLoc = mapView.userLocation!
userLoc.title = "Hello"
userLoc.subtitle = "I am …Run Code Online (Sandbox Code Playgroud) 我有一个我确定的坐标区域包含我想要为我的应用程序显示的限制.我把它设置为MKCoordinateRegion,中心点为lat,经度和跨度.如何确定当前userLocation是否在我的坐标区域内?
我已阅读并按照说明如何在没有CLLocationManager的情况下将MKMapView缩放到用户当前位置?
然而,虽然我确实得到了当前的用户位置,但我实际上无法使地图在视觉上居中.
例如,在viewDidLoad函数中,如何使地图围绕用户已知位置进行可视化居中?我已粘贴下面CurrentLocation的代码(请参阅viewDidLoad中的XXX注释
#import "MapViewController.h"
#import "PlacemarkViewController.h"
@implementation MapViewController
@synthesize mapView, reverseGeocoder, getAddressButton;
- (void)viewDidLoad
{
[super viewDidLoad];
// XXX HERE: How can I cause self.mapView to actually recenter itself at self.mapview.userLocation.location?
mapView.showsUserLocation = YES;
}
- (void)viewDidUnload
{
self.mapView = nil;
self.getAddressButton = nil;
}
- (void)dealloc
{
[reverseGeocoder release];
[mapView release];
[getAddressButton release];
[super dealloc];
}
- (IBAction)reverseGeocodeCurrentLocation
{
self.reverseGeocoder =
[[[MKReverseGeocoder alloc] initWithCoordinate:mapView.userLocation.location.coordinate] autorelease];
reverseGeocoder.delegate = self;
[reverseGeocoder start];
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
{ …Run Code Online (Sandbox Code Playgroud) 我使用以下代码来获取我当前的位置.但我面临的问题是,纬度和经度总是返回0.0.我已打开手机中的GPS设置并设置所有权限.但我仍然面对这个问题.
locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
customLocationListener = new CustomLocationListener();
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
0,
0,
customLocationListener);
class CustomLocationListener implements LocationListener{ ............
public void onLocationChanged(Location argLocation) {
if(location != null) {
int latitude=(int)(argLocation.getLatitude()*1E6);
int longitude=(int)(argLocation.getLongitude()*1E6);
}
} ........ }
Run Code Online (Sandbox Code Playgroud)
你们中的任何人都知道为什么吗?
注意:我的活动扩展了MapActivity而不是Location Listener
我有一个mapView与annotationViews和userLocation蓝点.
我使用以下代码获取蓝点:
[self.mapView setShowsUserLocation:YES];
Run Code Online (Sandbox Code Playgroud)
该annotationViews可选择,并有标注.
但是,如果一个annotationView接近用户的位置,有时蓝点会窃取触摸.
我可以设置一个annotationView.enabled = NO;,它会显示annotationView但它不会从附近偷一个触摸annotationView.
我想将用户位置蓝点设置annotationView为enabled = NO,因此它不会触及附近的触摸annotationViews.
我可以设置蓝点的标题:
self.mapView.userLocation.title = @"title here..."
Run Code Online (Sandbox Code Playgroud)
但我无法禁用蓝点.
谢谢!
我们可以更改此文本吗?
我已经使用属性purpose的CLLocationManager类.但是消息没有改变.
[locationManager setPurpose:@"Change text message"];
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
谢谢,
userlocation ×10
ios ×6
iphone ×4
mkmapview ×4
map ×2
mapkit ×2
objective-c ×2
android ×1
center ×1
delegates ×1
game-center ×1
geolocation ×1
google-maps ×1
gps ×1
info.plist ×1
ios5 ×1
location ×1
mapbox ×1
mkannotation ×1
swift ×1
xcode ×1