지도에서 현재 위치를 표시하는 앱을 만들고 있지만이지도는 Google지도가 아닌 이미지입니다. 내가 어떻게 할 수 있니? Google지도가 아닌지도를 사용하십시오.Google지도가 아닌지도에서 일부 사용자 위치를 표시하려면 어떻게해야합니까?
Google지도 좌표를이지도와 연결하는 것이 가능하다면,이 좌표를 얻기 위해 코어 위치를 사용하고 싶습니다.
모든 ideias?
지도에서 현재 위치를 표시하는 앱을 만들고 있지만이지도는 Google지도가 아닌 이미지입니다. 내가 어떻게 할 수 있니? Google지도가 아닌지도를 사용하십시오.Google지도가 아닌지도에서 일부 사용자 위치를 표시하려면 어떻게해야합니까?
Google지도 좌표를이지도와 연결하는 것이 가능하다면,이 좌표를 얻기 위해 코어 위치를 사용하고 싶습니다.
모든 ideias?
FAI 지구본 및 WGS-84 프로젝션에 대해 위도/경도 변환을 위해 만든 클래스입니다. 기본 지리적 포인트 (예 :지도의 중심)로 초기화하고 해당 포인트와 다른 포인트 사이의 거리를 미터로 계산합니다. 지도의 미터/픽셀 해상도를 알면 쉽게 픽셀 값으로 변환 할 수 있습니다.
클래스에 대한 문서는 많지 않지만 알아낼 수는 있습니다. 그것은 다른 종류의 광산 (Vector)을 사용하지만 CGPoint로 쉽게 대체 할 수 있어야합니다.
주의 : 소규모지도에서는 작동하지 않습니다. 대규모지도를 가정 할 때 빠른 계산 시간에 최적화되어 있습니다 (예 : 100km 미만).
.H 파일 :
//
// Earth.h
//
// Created by René Dekker on 01/10/2011.
// Copyright 2011. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import "Vector.h"
enum EarthModel {
EarthModelFAI = 0,
EarthModelWGS84 = 1
};
@interface Earth : NSObject {
enum EarthModel theModel;
double theLongitudeScale;
double theLatitudeScale;
CLLocationCoordinate2D baseLocation;
}
@property CLLocationCoordinate2D baseLocation;
+ (Earth *)earthModel:(enum EarthModel)model atLatitude:(double)baseLatitude;
- (void) rebaseAtLatitude:(double)baseLatitude;
+ (Earth *)earthAtLocation:(CLLocationCoordinate2D)location model:(enum EarthModel)model;
- (void) rebaseAtLocation:(CLLocationCoordinate2D)location;
- (Vector *) differenceBetween:(CLLocationCoordinate2D)first and:(CLLocationCoordinate2D)second;
- (double) distanceBetween:(CLLocationCoordinate2D)first and:(CLLocationCoordinate2D)second;
- (CLLocationCoordinate2D) addTo:(CLLocationCoordinate2D)location vector:(Vector *)vector;
- (double) addToLongitude:(double)longitude distance:(double)distance;
- (double) addToLatitude:(double)latitude distance:(double)distance;
- (Vector *) vectorFromBase:(CLLocationCoordinate2D)location;
- (double) distanceFromBase:(CLLocationCoordinate2D)location;
- (CLLocationCoordinate2D) addToBase:(Vector *)vector;
@end
하는 .m 파일 :
//
// Earth.m
//
// Created by René Dekker on 01/10/2011.
// Copyright 2011. All rights reserved.
//
// The information and formulas used in the WGS84 computations come mainly from:
// http://en.wikipedia.org/wiki/World_Geodetic_System
// http://en.wikipedia.org/wiki/Meridian_arc#Meridian_distance_on_the_ellipsoid
// http://www.holoscenes.com/cgi-bin/moin.cgi/Ellipsoid
// http://www.movable-type.co.uk/scripts/gis-faq-5.1.html
// http://williams.best.vwh.net/avform.htm
//
#import "Earth.h"
#define WGS_EQUATOR_R 6378137.0
#define WGS_POLAR_R 6356752.314245
#define F (1/298.257223563)
#define E2 (F * (2 - F))
#define FAI_R 6371000
@implementation Earth
double modTo(double x, double lower, double upper)
{
double range = upper - lower;
double result = fmod(x - lower, range);
if (result < 0) {
result += range;
}
return result + lower;
}
- (void) rebaseAtLatitude:(double)baseLatitude
{
baseLatitude *= PI_DEGREE;
if (theModel == EarthModelWGS84) {
double sinLat = sin(baseLatitude);
double factor = sqrt(1 - E2*sinLat*sinLat);
theLatitudeScale = PI_DEGREE * WGS_EQUATOR_R * (1-E2)/pow(factor, 3);
theLongitudeScale = PI_DEGREE * WGS_EQUATOR_R * cos(baseLatitude)/factor;
} else {
theLatitudeScale = PI_DEGREE * FAI_R;
theLongitudeScale = PI_DEGREE * FAI_R * cos(baseLatitude);
}
}
- (void) rebaseAtLocation:(CLLocationCoordinate2D)location
{
baseLocation = location;
[self rebaseAtLatitude:location.latitude];
}
- (CLLocationCoordinate2D) baseLocation
{
return baseLocation;
}
- (void) setBaseLocation:(CLLocationCoordinate2D)location
{
baseLocation = location;
[self rebaseAtLatitude:location.latitude];
}
- (Earth *) initWithModel:(enum EarthModel)model atLocation:(CLLocationCoordinate2D)location
{
if (!(self = [super init])) {
return nil;
}
theModel = model;
[self rebaseAtLocation:location];
return self;
}
+ (Earth *)earthModel:(enum EarthModel)model atLatitude:(double)baseLatitude
{
CLLocationCoordinate2D location = CLLocationCoordinate2DMake(baseLatitude, 0);
return [[[Earth alloc] initWithModel:model atLocation:location] autorelease];
}
+ (Earth *)earthAtLocation:(CLLocationCoordinate2D)location model:(enum EarthModel)model
{
return [[[Earth alloc] initWithModel:model atLocation:location] autorelease];
}
- (Vector *) differenceBetween:(CLLocationCoordinate2D)first and:(CLLocationCoordinate2D)second
{
double dx = modTo(first.longitude - second.longitude, -180, 180) * theLongitudeScale;
double dy = (first.latitude - second.latitude) * theLatitudeScale;
return [Vector withX:dx y:dy];
}
- (double) distanceBetween:(CLLocationCoordinate2D)first and:(CLLocationCoordinate2D)second
{
double dx = modTo(first.longitude - second.longitude, -180, 180) * theLongitudeScale;
double dy = (first.latitude - second.latitude) * theLatitudeScale;
return hypot(dx, dy);
}
- (CLLocationCoordinate2D) addTo:(CLLocationCoordinate2D)location vector:(Vector *)vector
{
location.latitude += vector.y/theLatitudeScale;
location.longitude += modTo(vector.x/theLongitudeScale, -180, 180);
return location;
}
- (Vector *) vectorFromBase:(CLLocationCoordinate2D)location
{
return [self differenceBetween:location and:baseLocation];
}
- (double) distanceFromBase:(CLLocationCoordinate2D)location
{
return [self distanceBetween:location and:baseLocation];
}
- (CLLocationCoordinate2D) addToBase:(Vector *)vector
{
return [self addTo:baseLocation vector:vector];
}
- (double) addToLongitude:(double)longitude distance:(double)distance
{
return modTo(longitude + distance/theLongitudeScale, -180, 180);
}
- (double) addToLatitude:(double)latitude distance:(double)distance
{
return latitude + distance/theLatitudeScale;
}
- (NSString *) description
{
return NSStringFromCLLocationCoordinate2D(baseLocation);
}
@end
이미지는 지역 참조되어야합니다.
지도의 투영 매개 변수를 알아야합니다.
이미지가 경도/위도 투영에 있지 않으면지도에서 사용하는 것과 동일한 투영에 제공되는 좌표 좌표를 투영해야합니다.
나는 혼란 스럽다. 위도 + 경도 좌표는 Google지도에 고유하지 않습니다. 같은 페이지에 Google지도와 이미지가 둘 다 있습니까? 또는 이미지를 표시하고 싶습니까? Google은 또한 다음을 사용하여 이러한 서비스를 제공합니다. Static Maps API
내가 그것 때문에 방법으로 내 질문에 언급, Google지도를 사용하지 않는 (즉, 내가 생각)을 사용하여 내지도를 지리 참조해야합니다. 핵심 위치 데이터를 사용하기 위해 지구상에있는 실제 지구 위치에서 내지도를 참조해야합니다. – douglasd3
고마워요! 하지만 건물처럼 작은 규모의지도가 필요합니다. 적응할 수있는 방법이 있습니까? – douglasd3
건물은 실제로 대규모지도라고 불리는 곳입니다. (혼돈 스럽습니다 :-) 내 코드는 100km 미만의 모든지도에 완벽하게 적용될 수 있어야합니다. – fishinear