summaryrefslogtreecommitdiff
path: root/macosx
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-08-08 18:25:45 +0200
committerKonstantin Käfer <mail@kkaefer.com>2014-08-08 18:25:45 +0200
commit4657e6e02314a0f3cfa545b37376a4cedb14484c (patch)
tree0b837eddef4a92fcd85c2e48df510c8a51e7b78f /macosx
parenta045d9c9d4e7040b699f1fbab88893440969ffe9 (diff)
downloadqtlocation-mapboxgl-4657e6e02314a0f3cfa545b37376a4cedb14484c.tar.gz
use a file source object to abstract loading of resources
Diffstat (limited to 'macosx')
-rw-r--r--macosx/main.mm17
-rw-r--r--macosx/mapboxgl-app.gyp4
2 files changed, 9 insertions, 12 deletions
diff --git a/macosx/main.mm b/macosx/main.mm
index c61c9decb6..9ecc307c05 100644
--- a/macosx/main.mm
+++ b/macosx/main.mm
@@ -73,14 +73,17 @@ int main() {
GLFWView view;
mbgl::Map map(view);
+ URLHandler *handler = [[URLHandler alloc] init];
+ [handler setMap:&map];
+ NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
+ [appleEventManager setEventHandler:handler andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
+
// Load settings
mbgl::Settings_NSUserDefaults settings;
map.setLonLatZoom(settings.longitude, settings.latitude, settings.zoom);
map.setBearing(settings.bearing);
map.setDebug(settings.debug);
- URLHandler *handler = [[URLHandler alloc] init];
- [handler setMap:&map];
// Set access token if present
NSString *accessToken = [[NSProcessInfo processInfo] environment][@"MAPBOX_ACCESS_TOKEN"];
@@ -88,15 +91,9 @@ int main() {
if (accessToken) map.setAccessToken([accessToken cStringUsingEncoding:[NSString defaultCStringEncoding]]);
// Load style
- NSString *path = [[NSBundle mainBundle] pathForResource:@"style.min" ofType:@"js"];
- NSString *json = [NSString stringWithContentsOfFile:path
- encoding:[NSString defaultCStringEncoding]
- error:nil];
- map.setStyleJSON((std::string)[json cStringUsingEncoding:[NSString defaultCStringEncoding]]);
-
- NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
- [appleEventManager setEventHandler:handler andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL];
+ const std::string path([[[NSBundle mainBundle] pathForResource:@"style" ofType:@"json" inDirectory:@"styles/bright"] UTF8String]);
+ map.setStyleURL(std::string("file://") + path);
int ret = view.run();
diff --git a/macosx/mapboxgl-app.gyp b/macosx/mapboxgl-app.gyp
index 59dfc66470..480dc2a114 100644
--- a/macosx/mapboxgl-app.gyp
+++ b/macosx/mapboxgl-app.gyp
@@ -23,7 +23,6 @@
'mac_bundle': 1,
'mac_bundle_resources': [
'Icon.icns',
- '<(SHARED_INTERMEDIATE_DIR)/bin/style.min.js'
],
'xcode_settings': {
'SDKROOT': 'macosx',
@@ -40,7 +39,8 @@
'CLANG_ENABLE_OBJC_ARC': 'YES'
},
'dependencies': [
- '../mapboxgl.gyp:mapboxgl'
+ '../mapboxgl.gyp:bundle_styles',
+ '../mapboxgl.gyp:mapboxgl',
]
}
]