高德地图 clearmapmap.setzoom 什么意思

他的最新文章
他的热门文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)匿名用户不能发表回复!|1 #import &MAMapKit/MAMapKit.h&
3 @interface MAMapView (ZoomLevel)
4 - (NSUInteger)getZoomL
6 - (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate
zoomLevel:(NSUInteger)zoomLevel
animated:(BOOL)
10 - (void)zoomToFitMapA
MAMapView+ZoomLevel.m
Created by iMac on 14/12/2.
Copyright (c) 2014年 POTech. All rights reserved.
9 #import "MAMapView+ZoomLevel.h"
11 #define MERCATOR_OFFSET
12 #define MERCATOR_RADIUS 05395
14 @implementation MAMapView (ZoomLevel)
16 #pragma mark - Map conversion methods
18 - (double)longitudeToPixelSpaceX:(double)longitude
return round(MERCATOR_OFFSET + MERCATOR_RADIUS * longitude * M_PI / 180.0);
23 - (double)latitudeToPixelSpaceY:(double)latitude
return round(MERCATOR_OFFSET - MERCATOR_RADIUS * logf((1 + sinf(latitude * M_PI / 180.0)) / (1 - sinf(latitude * M_PI / 180.0))) / 2.0);
28 - (double)pixelSpaceXToLongitude:(double)pixelX
return ((round(pixelX) - MERCATOR_OFFSET) / MERCATOR_RADIUS) * 180.0 / M_PI;
33 - (double)pixelSpaceYToLatitude:(double)pixelY
return (M_PI / 2.0 - 2.0 * atan(exp((round(pixelY) - MERCATOR_OFFSET) / MERCATOR_RADIUS))) * 180.0 / M_PI;
38 #pragma mark - Helper methods
40 - (MACoordinateSpan)coordinateSpanWithMapView:(MAMapView *)mapView
centerCoordinate:(CLLocationCoordinate2D)centerCoordinate
andZoomLevel:(NSUInteger)zoomLevel
// convert center coordiate to pixel space
double centerPixelX = [self longitudeToPixelSpaceX:centerCoordinate.longitude];
double centerPixelY = [self latitudeToPixelSpaceY:centerCoordinate.latitude];
// determine the scale value from the zoom level
NSInteger zoomExponent = 20 - zoomL
double zoomScale = pow(2, zoomExponent);
// scale the map&s size in pixel space
CGSize mapSizeInPixels = mapView.bounds.
double scaledMapWidth = mapSizeInPixels.width * zoomS
double scaledMapHeight = mapSizeInPixels.height * zoomS
// figure out the position of the top-left pixel
double topLeftPixelX = centerPixelX - (scaledMapWidth / 2);
double topLeftPixelY = centerPixelY - (scaledMapHeight / 2);
// find delta between left and right longitudes
CLLocationDegrees minLng = [self pixelSpaceXToLongitude:topLeftPixelX];
CLLocationDegrees maxLng = [self pixelSpaceXToLongitude:topLeftPixelX + scaledMapWidth];
CLLocationDegrees longitudeDelta = maxLng - minL
// find delta between top and bottom latitudes
CLLocationDegrees minLat = [self pixelSpaceYToLatitude:topLeftPixelY];
CLLocationDegrees maxLat = [self pixelSpaceYToLatitude:topLeftPixelY + scaledMapHeight];
CLLocationDegrees latitudeDelta = -1 * (maxLat - minLat);
// create and return the lat/lng span
MACoordinateSpan span = MACoordinateSpanMake(latitudeDelta, longitudeDelta);
76 #pragma mark - Public methods
78 - (NSUInteger)getZoomLevel
return 21-round(log2(self.region.span.longitudeDelta * MERCATOR_RADIUS * M_PI / (180.0 * self.bounds.size.width)));
83 - (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate
zoomLevel:(NSUInteger)zoomLevel
animated:(BOOL)animated
// clamp large numbers to 28
zoomLevel = MIN(zoomLevel, 28);
// use the zoom level to compute the region
MACoordinateSpan span = [self coordinateSpanWithMapView:self centerCoordinate:centerCoordinate andZoomLevel:zoomLevel];
MACoordinateRegion region = MACoordinateRegionMake(centerCoordinate, span);
// set the region like normal
[self setRegion:region animated:animated];
98 - (void)zoomToFitMapAnnotations
if ([self.annotations count] == 0) return;
CLLocationCoordinate2D topLeftC
topLeftCoord.latitude = -90;
topLeftCoord.longitude = 180;
CLLocationCoordinate2D bottomRightC
bottomRightCoord.latitude = 90;
bottomRightCoord.longitude = -180;
for(id&MAAnnotation& annotation in self.annotations) {
if ([annotation isKindOfClass:[MAUserLocation class]]) {
topLeftCoord.longitude = fmin(topLeftCoord.longitude, annotation.coordinate.longitude);
topLeftCoord.latitude = fmax(topLeftCoord.latitude, annotation.coordinate.latitude);
bottomRightCoord.longitude = fmax(bottomRightCoord.longitude, annotation.coordinate.longitude);
bottomRightCoord.latitude = fmin(bottomRightCoord.latitude, annotation.coordinate.latitude);
MACoordinateR
region.center.latitude = topLeftCoord.latitude - (topLeftCoord.latitude - bottomRightCoord.latitude) * 0.5;
region.center.longitude = topLeftCoord.longitude + (bottomRightCoord.longitude - topLeftCoord.longitude) * 0.5;
region.span.latitudeDelta = fabs(topLeftCoord.latitude - bottomRightCoord.latitude) * 1.2;
region.span.longitudeDelta = fabs(bottomRightCoord.longitude - topLeftCoord.longitude) * 1.2;
region = [self regionThatFits:region];
[self setRegion:region animated:YES];
阅读(...) 评论()高德地图实例代码及图片处理_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
高德地图实例代码及图片处理
&&高德地图示例代码
阅读已结束,下载本文需要
想免费下载更多文档?
定制HR最喜欢的简历
你可能喜欢他的最新文章
他的热门文章
您举报文章:
举报原因:
原文地址:
原因补充:
(最多只允许输入30个字)}

我要回帖

更多关于 高德地图 getmap null 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信