Plumbed camera options all the way through to MGLMapView. Added a method that lets you specify a direction in addition to center point and zoom level. Added Map::jumpTo() for parity with mapbox-gl-js. Replaced usage of Map::setLatLng() and Map::setLatLngZoom() with Map::jumpTo() or Map::easeTo() within MGLMapView. Replaced MGLMapView.pitch with MGLMapCamera for setting all supported degrees of freedom simultaneously. Simultaneously move and rotate with course. Support customizable timing functions on iOS. iosapp now persists an archived MGLMapCamera instead of separate viewpoint properties and also synchronizes user defaults on termination. This change implements persistence entirely in Objective-C, eliminating the use of the Objective-C++ implementation. Fixes #1643, fixes #1834. Ref #1581.
70 lines
1.3 KiB
C++
70 lines
1.3 KiB
C++
#ifndef MAPBOX_UTIL_OPTIONAL_HPP
|
|
#define MAPBOX_UTIL_OPTIONAL_HPP
|
|
|
|
#include <type_traits>
|
|
|
|
#include <mbgl/util/variant.hpp>
|
|
|
|
namespace mapbox
|
|
{
|
|
namespace util
|
|
{
|
|
|
|
template <typename T> class optional
|
|
{
|
|
static_assert(!std::is_reference<T>::value, "optional doesn't support references");
|
|
|
|
struct none_type
|
|
{
|
|
};
|
|
|
|
variant<none_type, T> variant_;
|
|
|
|
public:
|
|
optional() = default;
|
|
|
|
optional(optional const &rhs)
|
|
{
|
|
if (this != &rhs)
|
|
{ // protect against invalid self-assignment
|
|
variant_ = rhs.variant_;
|
|
}
|
|
}
|
|
|
|
optional(T const &v) { variant_ = v; }
|
|
|
|
explicit operator bool() const noexcept { return variant_.template is<T>(); }
|
|
|
|
T const &get() const { return variant_.template get<T>(); }
|
|
T &get() { return variant_.template get<T>(); }
|
|
|
|
T const &operator*() const { return this->get(); }
|
|
T operator*() { return this->get(); }
|
|
|
|
optional &operator=(T const &v)
|
|
{
|
|
variant_ = v;
|
|
return *this;
|
|
}
|
|
|
|
optional &operator=(optional const &rhs)
|
|
{
|
|
if (this != &rhs)
|
|
{
|
|
variant_ = rhs.variant_;
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
template <typename... Args> void emplace(Args &&... args)
|
|
{
|
|
variant_ = T{std::forward<Args>(args)...};
|
|
}
|
|
|
|
void reset() { variant_ = none_type{}; }
|
|
};
|
|
}
|
|
}
|
|
|
|
#endif
|