[core] Add MapOptions to define properties of Map

To simplify the Map constructor, introduce MapOptions
interface to define the properties that can be set on
a Map.
This commit is contained in:
Sudarsana Babu Nagineni
2019-03-07 14:29:19 +02:00
parent c4115f0539
commit 5e2b6bf636
26 changed files with 326 additions and 50 deletions

View File

@@ -616,11 +616,13 @@ void NodeMap::cancel() {
});
frontend = std::make_unique<mbgl::HeadlessFrontend>(mbgl::Size{ 256, 256 }, pixelRatio, *this, threadpool);
mbgl::MapOptions options;
options.withMapMode(mode)
.withConstrainMode(mbgl::ConstrainMode::HeightOnly)
.withViewportMode(mbgl::ViewportMode::Default)
.withCrossSourceCollisions(crossSourceCollisions);
map = std::make_unique<mbgl::Map>(*frontend, mapObserver, frontend->getSize(), pixelRatio,
*this, threadpool, mode,
mbgl::ConstrainMode::HeightOnly,
mbgl::ViewportMode::Default,
crossSourceCollisions);
*this, threadpool, options);
// FIXME: Reload the style after recreating the map. We need to find
// a better way of canceling an ongoing rendering on the core level
@@ -1205,10 +1207,10 @@ NodeMap::NodeMap(v8::Local<v8::Object> options)
pixelRatio,
*this,
threadpool,
mode,
mbgl::ConstrainMode::HeightOnly,
mbgl::ViewportMode::Default,
crossSourceCollisions)),
mbgl::MapOptions().withMapMode(mode)
.withConstrainMode(mbgl::ConstrainMode::HeightOnly)
.withViewportMode(mbgl::ViewportMode::Default)
.withCrossSourceCollisions(crossSourceCollisions))),
async(new uv_async_t) {
async->data = this;