diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-06-20 17:12:58 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-06-22 08:04:39 -0700 |
commit | 40e47556214e999c952c1e88e026d673cdd96c72 (patch) | |
tree | e8d15795cbecc07c94908a8ebed31b73def64614 /platform | |
parent | 1520a56813f82bbe875774fdc2b3df26392278d6 (diff) | |
download | qtlocation-mapboxgl-40e47556214e999c952c1e88e026d673cdd96c72.tar.gz |
[core] Move setStyleJSON/URL to Style; add Map::setStyle
Diffstat (limited to 'platform')
-rwxr-xr-x | platform/android/src/native_map_view.cpp | 8 | ||||
-rw-r--r-- | platform/darwin/src/MGLStyle.mm | 2 | ||||
-rw-r--r-- | platform/glfw/main.cpp | 5 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 6 | ||||
-rw-r--r-- | platform/macos/src/MGLMapView.mm | 9 | ||||
-rw-r--r-- | platform/node/src/node_map.cpp | 6 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 8 |
7 files changed, 23 insertions, 21 deletions
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp index e09a58d25f..13d5be01b9 100755 --- a/platform/android/src/native_map_view.cpp +++ b/platform/android/src/native_map_view.cpp @@ -344,19 +344,19 @@ void NativeMapView::resizeFramebuffer(jni::JNIEnv&, int w, int h) { } jni::String NativeMapView::getStyleUrl(jni::JNIEnv& env) { - return jni::Make<jni::String>(env, map->getStyleURL()); + return jni::Make<jni::String>(env, map->getStyle().getURL()); } void NativeMapView::setStyleUrl(jni::JNIEnv& env, jni::String url) { - map->setStyleURL(jni::Make<std::string>(env, url)); + map->getStyle().loadURL(jni::Make<std::string>(env, url)); } jni::String NativeMapView::getStyleJson(jni::JNIEnv& env) { - return jni::Make<jni::String>(env, map->getStyleJSON()); + return jni::Make<jni::String>(env, map->getStyle().getJSON()); } void NativeMapView::setStyleJson(jni::JNIEnv& env, jni::String json) { - map->setStyleJSON(jni::Make<std::string>(env, json)); + map->getStyle().loadJSON(jni::Make<std::string>(env, json)); } void NativeMapView::setLatLngBounds(jni::JNIEnv& env, jni::Object<mbgl::android::LatLngBounds> jBounds) { diff --git a/platform/darwin/src/MGLStyle.mm b/platform/darwin/src/MGLStyle.mm index 6d9a12c3e0..2365641f02 100644 --- a/platform/darwin/src/MGLStyle.mm +++ b/platform/darwin/src/MGLStyle.mm @@ -124,7 +124,7 @@ static NSURL *MGLStyleURL_emerald; } - (NSURL *)URL { - return [NSURL URLWithString:@(self.mapView.mbglMap->getStyleURL().c_str())]; + return [NSURL URLWithString:@(self.rawStyle->getURL().c_str())]; } - (NSString *)name { diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp index 97c77b3742..7192475835 100644 --- a/platform/glfw/main.cpp +++ b/platform/glfw/main.cpp @@ -6,6 +6,7 @@ #include <mbgl/util/platform.hpp> #include <mbgl/util/default_thread_pool.hpp> #include <mbgl/storage/default_file_source.hpp> +#include <mbgl/style/style.hpp> #include <csignal> #include <getopt.h> @@ -147,7 +148,7 @@ int main(int argc, char *argv[]) { } mbgl::util::default_styles::DefaultStyle newStyle = mbgl::util::default_styles::orderedStyles[currentStyleIndex]; - map.setStyleURL(newStyle.url); + map.getStyle().loadURL(newStyle.url); view->setWindowTitle(newStyle.name); mbgl::Log::Info(mbgl::Event::Setup, "Changed style to: %s", newStyle.name); @@ -178,7 +179,7 @@ int main(int argc, char *argv[]) { } } - map.setStyleURL(style); + map.getStyle().loadURL(style); view->run(); diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 0d00fe75fb..6c6d8d2980 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -373,7 +373,7 @@ public: - (nonnull NSURL *)styleURL { - NSString *styleURLString = @(_mbglMap->getStyleURL().c_str()).mgl_stringOrNilIfEmpty; + NSString *styleURLString = @(_mbglMap->getStyle().getURL().c_str()).mgl_stringOrNilIfEmpty; NSAssert(styleURLString || _isTargetingInterfaceBuilder, @"Invalid style URL string %@", styleURLString); return styleURLString ? [NSURL URLWithString:styleURLString] : nil; } @@ -389,12 +389,12 @@ public: styleURL = styleURL.mgl_URLByStandardizingScheme; self.style = nil; - _mbglMap->setStyleURL([[styleURL absoluteString] UTF8String]); + _mbglMap->getStyle().loadURL([[styleURL absoluteString] UTF8String]); } - (IBAction)reloadStyle:(__unused id)sender { NSURL *styleURL = self.styleURL; - _mbglMap->setStyleURL(""); + _mbglMap->getStyle().loadURL(""); self.styleURL = styleURL; } diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 756f237fba..0a567a8510 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -24,6 +24,7 @@ #import <mbgl/map/map.hpp> #import <mbgl/map/view.hpp> +#import <mbgl/style/style.hpp> #import <mbgl/annotation/annotation.hpp> #import <mbgl/map/camera.hpp> #import <mbgl/storage/reachability.h> @@ -239,7 +240,7 @@ public: // If the Style URL inspectable was not set, make sure to go through // -setStyleURL: to load the default style. - if (_mbglMap->getStyleURL().empty()) { + if (_mbglMap->getStyle().getURL().empty()) { self.styleURL = nil; } } @@ -607,7 +608,7 @@ public: } - (nonnull NSURL *)styleURL { - NSString *styleURLString = @(_mbglMap->getStyleURL().c_str()).mgl_stringOrNilIfEmpty; + NSString *styleURLString = @(_mbglMap->getStyle().getURL().c_str()).mgl_stringOrNilIfEmpty; return styleURLString ? [NSURL URLWithString:styleURLString] : [MGLStyle streetsStyleURLWithVersion:MGLStyleDefaultVersion]; } @@ -629,12 +630,12 @@ public: styleURL = styleURL.mgl_URLByStandardizingScheme; self.style = nil; - _mbglMap->setStyleURL(styleURL.absoluteString.UTF8String); + _mbglMap->getStyle().loadURL(styleURL.absoluteString.UTF8String); } - (IBAction)reloadStyle:(__unused id)sender { NSURL *styleURL = self.styleURL; - _mbglMap->setStyleURL(""); + _mbglMap->getStyle().loadURL(""); self.styleURL = styleURL; } diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 324b53f843..9ba88193c9 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -214,7 +214,7 @@ void NodeMap::Load(const Nan::FunctionCallbackInfo<v8::Value>& info) { } try { - nodeMap->map->setStyleJSON(style); + nodeMap->map->getStyle().loadJSON(style); } catch (const std::exception &ex) { return Nan::ThrowError(ex.what()); } @@ -528,7 +528,7 @@ void NodeMap::Cancel(const Nan::FunctionCallbackInfo<v8::Value>& info) { } void NodeMap::cancel() { - auto style = map->getStyleJSON(); + auto style = map->getStyle().getJSON(); map = std::make_unique<mbgl::Map>(backend, mbgl::Size{ 256, 256 }, pixelRatio, *this, threadpool, mbgl::MapMode::Still); @@ -536,7 +536,7 @@ void NodeMap::cancel() { // FIXME: Reload the style after recreating the map. We need to find // a better way of canceling an ongoing rendering on the core level // without resetting the map, which is way too expensive. - map->setStyleJSON(style); + map->getStyle().loadJSON(style); error = std::make_exception_ptr(std::runtime_error("Canceled")); renderFinished(); diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index cb48308682..f094e2a0ec 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -475,12 +475,12 @@ void QMapboxGL::cycleDebugOptions() */ QString QMapboxGL::styleJson() const { - return QString::fromStdString(d_ptr->mapObj->getStyleJSON()); + return QString::fromStdString(d_ptr->mapObj->getStyle().getJSON()); } void QMapboxGL::setStyleJson(const QString &style) { - d_ptr->mapObj->setStyleJSON(style.toStdString()); + d_ptr->mapObj->getStyle().loadJSON(style.toStdString()); } /*! @@ -500,12 +500,12 @@ void QMapboxGL::setStyleJson(const QString &style) */ QString QMapboxGL::styleUrl() const { - return QString::fromStdString(d_ptr->mapObj->getStyleURL()); + return QString::fromStdString(d_ptr->mapObj->getStyle().getURL()); } void QMapboxGL::setStyleUrl(const QString &url) { - d_ptr->mapObj->setStyleURL(url.toStdString()); + d_ptr->mapObj->getStyle().loadURL(url.toStdString()); } /*! |