From 11afef7825d622a237fa026e45e6d61b4de94068 Mon Sep 17 00:00:00 2001 From: Sudarsana Babu Nagineni Date: Mon, 25 Mar 2019 23:39:31 +0200 Subject: [core] Add interface to change the orientation through MapOptions --- src/mbgl/map/map.cpp | 7 ++----- src/mbgl/map/map_impl.cpp | 1 + src/mbgl/map/map_options.cpp | 10 ++++++++++ 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index e609e22c97..06c637b232 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -326,10 +326,6 @@ void Map::setNorthOrientation(NorthOrientation orientation) { impl->onUpdate(); } -NorthOrientation Map::getNorthOrientation() const { - return impl->transform.getNorthOrientation(); -} - #pragma mark - Constrain mode void Map::setConstrainMode(mbgl::ConstrainMode mode) { @@ -351,7 +347,8 @@ MapOptions Map::getMapOptions() const { .withMapMode(impl->mode) .withConstrainMode(impl->transform.getConstrainMode()) .withViewportMode(impl->transform.getViewportMode()) - .withCrossSourceCollisions(impl->crossSourceCollisions)); + .withCrossSourceCollisions(impl->crossSourceCollisions) + .withNorthOrientation(impl->transform.getNorthOrientation())); } #pragma mark - Projection mode diff --git a/src/mbgl/map/map_impl.cpp b/src/mbgl/map/map_impl.cpp index 348e26700f..cdc8c231e4 100644 --- a/src/mbgl/map/map_impl.cpp +++ b/src/mbgl/map/map_impl.cpp @@ -24,6 +24,7 @@ Map::Impl::Impl(RendererFrontend& frontend_, fileSource(std::move(fileSource_)), style(std::make_unique(scheduler, *fileSource, pixelRatio)), annotationManager(*style) { + transform.setNorthOrientation(mapOptions.northOrientation()); style->impl->setObserver(this); rendererFrontend.setObserver(*this); transform.resize(size_); diff --git a/src/mbgl/map/map_options.cpp b/src/mbgl/map/map_options.cpp index 7c254476d6..b4ad38ac7f 100644 --- a/src/mbgl/map/map_options.cpp +++ b/src/mbgl/map/map_options.cpp @@ -7,6 +7,7 @@ public: MapMode mapMode = MapMode::Continuous; ConstrainMode constrainMode = ConstrainMode::HeightOnly; ViewportMode viewportMode = ViewportMode::Default; + NorthOrientation orientation = NorthOrientation::Upwards; bool crossSourceCollisions = true; }; @@ -51,4 +52,13 @@ bool MapOptions::crossSourceCollisions() const { return impl_->crossSourceCollisions; } +MapOptions& MapOptions::withNorthOrientation(NorthOrientation orientation) { + impl_->orientation = orientation; + return *this; +} + +NorthOrientation MapOptions::northOrientation() const { + return impl_->orientation; +} + } // namespace mbgl -- cgit v1.2.1