From 6e41664cb033ee5edf6ae5ac66ed518d9f0d1f89 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Mon, 16 Feb 2015 09:52:36 -0800 Subject: fixes #476 & #853: pixel/meter/latlng conversion routines in core & iOS --- macosx/main.mm | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'macosx/main.mm') 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 #include +#include + #import @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(); -- cgit v1.2.1