手机ios系统自带地图定位位错误怎么办

微信小程序开发之真机测试 地图定位 map API 无法获取当前位置的问题
微信小程序开发之真机测试 地图定位 map API 无法获取当前位置的问题
微信小程序Mini App
今天做到地图定位的模块.模拟器肯定是获取不到位置的.下面为真机结果.
经纬度不说了.定位用的,我这里直接输入的数字定位.但是有许多问题
下图中scale是缩放比例,这个属性目前无效.后期团队应该会修复.毕竟现在刚开始公测.这样就导致我不管怎么修改scale,我的地图都是在默认的缩放比例.如上图.
markers中的rotate是图标的旋转角度.如果需要平行于屏幕的图标,那就设置为0吧.
另外,覆盖物的图标是可以修改的.给iconPath设置路径即可.
上一段代码:
[javascript]&&
2.wx.getLocation(OBJECT)
获取当前位置API
红色框标出的就是经纬度,速度,精确度
用gch02返回的坐标可以直接打开地图.
3.wx.openLocation(OBJECT)
最简单粗暴的就是直接给经纬度定位.
[javascript]&&
真机测试 效果图:
我的热门文章
即使是一小步也想与你分享百度地图怎么纠错?百度地图位置报错的详细教程
我们知道百度地图上边有这样和那样的类型,那你知道那地方已经不再了,怎么报错给,百度地图,这样他们知道之后就会修改,避免其他人到这个地方找不到。
1、首先打开百度电脑里面的浏览器,然后我们来到百度首页搜索地图的关键字
2、然后我们就来到百度地图的官网上来,默认是北京地图。
3、然后我们点击上边的图标,这个图标为超市的图标,我们点击他一下,
4、出现地址和电话,还可以看街景,我们点击后面的纠错的按钮
5、我们来到反馈地图的页面上来
6、我们切换到上边的该地点不存在的选项卡
7、点击下边的提交就ok了
如果本文对您有帮助请分享给您的好友,也可按Ctrl+D收藏本页面,谢谢!
评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)&&&最新查询信息
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
&&本月活跃指数排行榜
城市分站:
门户网――中国易修网> 泊竹的博客详情
-&(void)startTrackingLocation&{
&&&&CLAuthorizationStatus&status&=&[CLLocationManager&authorizationStatus];
&&&&if&(status&==&kCLAuthorizationStatusNotDetermined)&{
&&&&&&&&[_locationManager&requestWhenInUseAuthorization];
&&&&else&if&(status&==&kCLAuthorizationStatusAuthorizedWhenInUse&||&status&==&kCLAuthorizationStatusAuthorizedAlways)&{
&&&&&&&&[_locationManager&startUpdatingLocation];
-&(void)locationManager:(CLLocationManager&*)manager&didChangeAuthorizationStatus:(CLAuthorizationStatus)status&{
&&&&switch&(status)&{
&&&&&&&&case&kCLAuthorizationStatusAuthorizedAlways:
&&&&&&&&case&kCLAuthorizationStatusAuthorizedWhenInUse:
&&&&&&&&&&&&NSLog(@"Got&authorization,&start&tracking&location");
&&&&&&&&&&&&[self&startTrackingLocation];
&&&&&&&&&&&&
&&&&&&&&case&kCLAuthorizationStatusNotDetermined:
&&&&&&&&&&&&[_locationManager&requestWhenInUseAuthorization];
&&&&&&&&default:
&&&&&&&&&&&&
if&(isIOS8)&{
&&&&&&&&_locationManager&=&[[CLLocationManager&alloc]&init];
&&&&&&&&_locationManager.delegate&=&
&&&&&&&&[self&startTrackingLocation];
另外,在项目的plist文件里设置key, 可以自定义授权弹窗的提示语。
上面的代码截取自苹果官方demo
&&&&Copyright&(C)&2014&Apple&Inc.&All&Rights&Reserved.
&&&&See&LICENSE.txt&for&this&sample’s&licensing&information
&&&&Abstract:
&&&&&&&&&&&&&&&&Primary&view&controller&for&what&is&displayed&by&the&application.
&&&&&&&&&&&&&&&&In&this&class&we&receieve&location&updates&from&Core&Location,&convert&them&to&x,y&coordinates&so&that&they&map&on&the&imageView
&&&&&&&&&&&&&&&&and&move&the&pinView&to&that&location
&&&&&&&&&&&&
#import&"AAPLViewController.h"
#import&"AAPLCoordinateConverter.h"
@interface&AAPLViewController&()&&CLLocationManagerDelegate&
@property&(nonatomic,&weak)&IBOutlet&UIImageView&*imageV
@property&(nonatomic,&weak)&IBOutlet&UIImageView&*pinV
@property&(nonatomic,&weak)&IBOutlet&UIImageView&*radiusV
@property&(nonatomic,&strong)&CLLocationManager&*locationM
@property&(nonatomic,&strong)&AAPLCoordinateConverter&*coordinateC
@property&CGFloat&displayS
@property&CGPoint&displayO
@property&(nonatomic)&AAPLGeoAnchorPair&anchorP
@implementation&AAPLViewController
-&(void)viewDidLoad&{
[super&viewDidLoad];
//&Setup&a&reference&to&location&manager.
self.locationManager&=&[[CLLocationManager&alloc]&init];
self.locationManager.delegate&=&
self.locationManager.desiredAccuracy&=&kCLLocationAccuracyB
&&&&self.locationManager.activityType&=&CLActivityTypeO
//&We&setup&a&pair&of&anchors&that&will&define&how&the&floorplan&image,&maps&to&geographic&co-ordinates
&&&&AAPLGeoAnchor&anchor1&=&{
&&&&&&&&.latitudeLongitude&=&CLLocationCoordinate2DMake(37.770511,&-122.465810),
&&&&&&&&.pixel&=&CGPointMake(12,&18)
&&&&AAPLGeoAnchor&anchor2&=&{
&&&&&&&&.latitudeLongitude&=&CLLocationCoordinate2DMake(37.769125,&-122.466356),
&&&&&&&&.pixel&=&CGPointMake(481,&815)
&&&&self.anchorPair&=&(AAPLGeoAnchorPair)&{
&&&&&&&&.fromAnchor&=&anchor1,
&&&&&&&&.toAnchor&=&anchor2
//&Initialize&the&coordinate&system&converter&with&two&anchor&points.
self.coordinateConverter&=&[[AAPLCoordinateConverter&alloc]&initWithAnchors:self.anchorPair];
-&(void)viewDidAppear:(BOOL)animated&{
&&&&[self&setScaleAndOffset];
&&&&[self&startTrackingLocation];
-&(void)&setScaleAndOffset&{
&&&&CGSize&imageViewFrameSize&=&self.imageView.frame.
&&&&CGSize&imageSize&=&self.imageView.image.
&&&&//&Calculate&how&much&we'll&be&scaling&the&image&to&fit&on&screen.
&&&&self.displayScale&=&MIN(imageViewFrameSize.width&/&imageSize.width,&imageViewFrameSize.height&/&imageSize.height);
&&&&NSLog(@"Scale&Factor:&%f",&self.displayScale);
&&&&//&Depending&on&whether&we're&constrained&by&width&or&height,
&&&&//&figure&out&how&much&our&floorplan&pixels&need&to&be&offset&to&adjust&for&the&image&being&centered
&&&&if&(imageViewFrameSize.width&/&imageSize.width&&&imageViewFrameSize.height&/&imageSize.height)&{
&&&&&&&&NSLog(@"Constrained&by&width");
&&&&&&&&self.displayOffset&=&CGPointMake(0,&(imageViewFrameSize.height&-&imageSize.height&*&self.displayScale)&/&2);
&&&&}&else&{
&&&&&&&&NSLog(@"Constrained&by&height");
&&&&&&&&self.displayOffset&=&CGPointMake((imageViewFrameSize.width&-&imageSize.width&*&self.displayScale)&/&2,&0);
&&&&NSLog(@"Offset:&%f,&%f",&self.displayOffset.x,&self.displayOffset.y);
-&(void)startTrackingLocation&{
CLAuthorizationStatus&status&=&[CLLocationManager&authorizationStatus];
&&&&if&(status&==&kCLAuthorizationStatusNotDetermined)&{
[self.locationManager&requestWhenInUseAuthorization];
&&&&else&if&(status&==&kCLAuthorizationStatusAuthorizedWhenInUse&||&status&==&kCLAuthorizationStatusAuthorizedAlways)&{
[self.locationManager&startUpdatingLocation];
-&(void)locationManager:(CLLocationManager&*)manager&didChangeAuthorizationStatus:(CLAuthorizationStatus)status&{
switch&(status)&{
case&kCLAuthorizationStatusAuthorizedAlways:
case&kCLAuthorizationStatusAuthorizedWhenInUse:
NSLog(@"Got&authorization,&start&tracking&location");
[self&startTrackingLocation];
&&&&&&&&&&&&
case&kCLAuthorizationStatusNotDetermined:
[self.locationManager&requestWhenInUseAuthorization];
-&(void)locationManager:(CLLocationManager&*)manager&didUpdateLocations:(NSArray&*)locations&{
&&&&//&Pass&location&updates&to&the&map&view.
[locations&enumerateObjectsUsingBlock:^(CLLocation&*location,&NSUInteger&idx,&BOOL&*stop)&{
&&&&&&&&NSLog(@"Location&(Floor&%@):&%@",&location.floor,&location.description);
[self&updateViewWithLocation:location];
-&(void)&updateViewWithLocation:&(CLLocation&*)&location&{
//&We&animate&transition&from&one&position&to&the&next,&this&makes&the&dot&move&smoothly&over&the&map
[UIView&animateWithDuration:0.75&animations:^&{
//&Call&the&converter&to&find&these&coordinates&on&our&floorplan.
CGPoint&pointOnImage&=&[self.coordinateConverter&pointFromCoordinate:location.coordinate];
//&These&coordinates&need&to&be&scaled&based&on&how&much&the&image&has&been&scaled
CGPoint&scaledPoint&=&CGPointMake(pointOnImage.x&*&self.displayScale&+&self.displayOffset.x,
&&pointOnImage.y&*&self.displayScale&+&self.displayOffset.y);
//&Calculate&and&set&the&size&of&the&radius
CGFloat&radiusFrameSize&=&location.horizontalAccuracy&*&self.coordinateConverter.pixelsPerMeter&*&2;
self.radiusView.frame&=&CGRectMake(0,&0,&radiusFrameSize,&radiusFrameSize);
//&Move&the&pin&and&radius&to&the&user's&location
self.pinView.center&=&scaledP
self.radiusView.center&=&scaledP
-&(void)&willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation&duration:(NSTimeInterval)duration&{
//&Upon&rotation,&we&want&to&resize&the&image&and&center&it&appropriately.
&&&&[self&setScaleAndOffset];
人打赏支持
码字总数 13285
从开发者网站下载的。重新编辑的这篇文章,添加了官方demo代码
支付宝支付
微信扫码支付
打赏金额: ¥
已支付成功
打赏金额: ¥
& 开源中国(OSChina.NET) |
开源中国社区(OSChina.net)是工信部
指定的官方社区查看: 31211|回复: 23
为什么我手机地带地图定位位置不对
& & 亲们&&为什么我手机地图定位的位置不对啊 老实我学校的位置 我现在都在家呆了好几个月了 定位还是学校的位置&&QQ等聊天工具搜的附近人都是我学校那附近的人 求解答
还原下网络设置看看。
吾光食色 发表于
还原下网络设置看看。
小白一个&&网络设置在哪 给点详细解答被 嘿嘿
还原下网络设置看看
<font color="#7908180 发表于
小白一个&&网络设置在哪 给点详细解答被 嘿嘿
设置--通用--还原
吾光食色 发表于
设置--通用--还原
还原了 还是不好用 地图显示的位置还是我学校的位置
<font color="#7908180 发表于
还原了 还是不好用 地图显示的位置还是我学校的位置
这么奇怪,那重启下手机
如果还不行,就还原所有设置吧。
如果越狱过了,变数就比较多。比如安装了位置欺骗应用等等。
手机定位偏差1公里很正常的
吾光食色 发表于
这么奇怪,那重启下手机
如果还不行,就还原所有设置吧。
如果越狱过了,变数就比较多。比如安装了位置 ...
哦哦&&我这个越狱过了&&还原所以设置 我下的软件什么还都在么
groundblack 发表于
手机定位偏差1公里很正常的
我在大连 我学校在沈阳 这偏差好像太大了
Powered by
北京市公安局海淀分局网监中心备案编号:

我要回帖

更多关于 ios自带地图定位不准 的文章

 

随机推荐