summaryrefslogtreecommitdiff
path: root/macosx
diff options
context:
space:
mode:
authorJustin R. Miller <incanus@codesorcery.net>2015-02-16 09:52:36 -0800
committerJustin R. Miller <incanus@codesorcery.net>2015-02-16 09:52:36 -0800
commit6e41664cb033ee5edf6ae5ac66ed518d9f0d1f89 (patch)
treea70192b174ea6dc69b1fa0b13f9a33358a9110e5 /macosx
parentea31ad99a56f1e0afbcc7862ddc62dffd16bc5bb (diff)
downloadqtlocation-mapboxgl-6e41664cb033ee5edf6ae5ac66ed518d9f0d1f89.tar.gz
fixes #476 & #853: pixel/meter/latlng conversion routines in core & iOS
Diffstat (limited to 'macosx')
-rw-r--r--macosx/main.mm24
1 files changed, 15 insertions, 9 deletions
diff --git a/macosx/main.mm b/macosx/main.mm
index d61d7d16bf..f59fbda6a8 100644
--- a/macosx/main.mm
+++ b/macosx/main.mm
@@ -7,6 +7,8 @@
#include <mbgl/storage/default/sqlite_cache.hpp>
#include <mbgl/storage/network_status.hpp>
+#include <mbgl/util/geo.hpp>
+
#import <Foundation/Foundation.h>
@interface URLHandler : NSObject
@@ -31,15 +33,16 @@
[params setObject:[parts objectAtIndex:1] forKey:[parts objectAtIndex:0]];
}
- double latitude = 0, longitude = 0, zoom = 0, bearing = 0;
+ mbgl::LatLng latLng = mbgl::LatLng(0, 0);
+ double zoom = 0, bearing = 0;
bool hasCenter = false, hasZoom = false, hasBearing = false;
NSString *centerString = [params objectForKey:@"center"];
if (centerString) {
- NSArray *latlon = [centerString componentsSeparatedByString:@","];
- if ([latlon count] == 2) {
- latitude = [[latlon objectAtIndex:0] doubleValue];
- longitude = [[latlon objectAtIndex:1] doubleValue];
+ NSArray *latLngValues = [centerString componentsSeparatedByString:@","];
+ if ([latLngValues count] == 2) {
+ latLng.latitude = [latLngValues[0] doubleValue];
+ latLng.longitude = [latLngValues[1] doubleValue];
hasCenter = true;
}
}
@@ -58,9 +61,9 @@
if ([self map]) {
if (hasCenter && hasZoom) {
- [self map]->setLonLatZoom(longitude, latitude, zoom);
+ [self map]->setLatLngZoom(latLng, zoom);
} else if (hasCenter) {
- [self map]->setLonLat(longitude, latitude);
+ [self map]->setLatLng(latLng);
} else if (hasZoom) {
[self map]->setZoom(zoom);
}
@@ -120,7 +123,7 @@ int main() {
// Load settings
mbgl::Settings_NSUserDefaults settings;
- map.setLonLatZoom(settings.longitude, settings.latitude, settings.zoom);
+ map.setLatLngZoom(mbgl::LatLng(settings.latitude, settings.longitude), settings.zoom);
map.setBearing(settings.bearing);
map.setDebug(settings.debug);
@@ -137,7 +140,10 @@ int main() {
[reachability stopNotifier];
// Save settings
- map.getLonLatZoom(settings.longitude, settings.latitude, settings.zoom);
+ mbgl::LatLng latLng = map.getLatLng();
+ settings.latitude = latLng.latitude;
+ settings.longitude = latLng.longitude;
+ settings.zoom = map.getZoom();
settings.bearing = map.getBearing();
settings.debug = map.getDebug();
settings.save();