expose LocationIndicatorLayer and an alternative rendering mode based on it

This commit is contained in:
Łukasz Paczos
2020-04-08 15:07:47 +02:00
parent d7161fca1f
commit 6bb456882a
39 changed files with 2479 additions and 635 deletions

View File

@@ -156,6 +156,8 @@ add_library(
${PROJECT_SOURCE_DIR}/style/layers/raster_layer.hpp
${PROJECT_SOURCE_DIR}/style/layers/symbol_layer.cpp
${PROJECT_SOURCE_DIR}/style/layers/symbol_layer.hpp
${PROJECT_SOURCE_DIR}/style/layers/location_indicator_layer.cpp
${PROJECT_SOURCE_DIR}/style/layers/location_indicator_layer.hpp
${PROJECT_SOURCE_DIR}/style/light.cpp
${PROJECT_SOURCE_DIR}/style/light.hpp
${PROJECT_SOURCE_DIR}/style/position.cpp

View File

@@ -52,11 +52,25 @@ Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, std::vect
return result;
}
Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, std::vector<double>>::operator()(jni::JNIEnv& env, const std::vector<double>& value) const {
auto result = jni::Array<jni::Double>::New(env, value.size());
for (std::size_t i = 0; i < value.size(); i++) {
result.Set(env, i, jni::Box(env, value.at(i)));
}
return result;
}
Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, style::expression::Image>::operator()(
jni::JNIEnv& env, const style::expression::Image& value) const {
return jni::Make<jni::String>(env, value.id());
}
Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, mbgl::style::Rotation>::operator()(jni::JNIEnv& env, const mbgl::style::Rotation& value) const {
return jni::Box(env, value.getAngle());
}
} // namespace conversion
} // namespace style
} // namespace mbgl

View File

@@ -13,6 +13,7 @@
#include <string>
#include <array>
#include <vector>
#include <mbgl/style/rotation.hpp>
namespace mbgl {
namespace android {
@@ -72,6 +73,17 @@ struct Converter<jni::Local<jni::Object<>>, std::array<float, N>> {
}
};
template <std::size_t N>
struct Converter<jni::Local<jni::Object<>>, std::array<double, N>> {
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const std::array<double, N>& value) const {
std::vector<double> v;
for (const double& id : value) {
v.push_back(id);
}
return convert<jni::Local<jni::Object<>>, std::vector<double>>(env, v);
}
};
template <>
struct Converter<jni::Local<jni::Object<>>, std::vector<std::string>> {
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const std::vector<std::string>& value) const;
@@ -82,6 +94,11 @@ struct Converter<jni::Local<jni::Object<>>, std::vector<float>> {
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const std::vector<float>& value) const;
};
template <>
struct Converter<jni::Local<jni::Object<>>, std::vector<double>> {
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const std::vector<double>& value) const;
};
template <class T>
struct Converter<jni::Local<jni::Object<>>, T, typename std::enable_if_t<std::is_enum<T>::value>> {
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const T& value) const {
@@ -105,6 +122,11 @@ struct Converter<jni::Local<jni::Object<>>, style::expression::Image> {
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const style::expression::Image& value) const;
};
template <>
struct Converter<jni::Local<jni::Object<>>, mbgl::style::Rotation> {
Result<jni::Local<jni::Object<>>> operator()(jni::JNIEnv& env, const mbgl::style::Rotation& value) const;
};
} // namespace conversion
} // namespace android
} // namespace mbgl

View File

@@ -26,13 +26,16 @@ namespace android {
/**
* Creates a non-owning peer object (for layers currently attached to the map)
*/
BackgroundLayer::BackgroundLayer(mbgl::style::BackgroundLayer& coreLayer) : Layer(coreLayer) {}
BackgroundLayer::BackgroundLayer(mbgl::style::BackgroundLayer& coreLayer)
: Layer(coreLayer) {
}
/**
* Creates an owning peer object (for layers not attached to the map)
*/
BackgroundLayer::BackgroundLayer(std::unique_ptr<mbgl::style::BackgroundLayer> coreLayer)
: Layer(std::move(coreLayer)) {}
: Layer(std::move(coreLayer)) {
}
BackgroundLayer::~BackgroundLayer() = default;
@@ -105,18 +108,14 @@ namespace android {
}
} // namespace
jni::Local<jni::Object<Layer>> BackgroundJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env,
mbgl::style::Layer& layer) {
jni::Local<jni::Object<Layer>> BackgroundJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, mbgl::style::Layer& layer) {
assert(layer.baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env, new BackgroundLayer(toBackgroundLayer(layer)));
}
jni::Local<jni::Object<Layer>> BackgroundJavaLayerPeerFactory::createJavaLayerPeer(
jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
jni::Local<jni::Object<Layer>> BackgroundJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
assert(layer->baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env,
new BackgroundLayer(std::unique_ptr<mbgl::style::BackgroundLayer>(
static_cast<mbgl::style::BackgroundLayer*>(layer.release()))));
return createJavaPeer(env, new BackgroundLayer(std::unique_ptr<mbgl::style::BackgroundLayer>(static_cast<mbgl::style::BackgroundLayer*>(layer.release()))));
}
void BackgroundJavaLayerPeerFactory::registerNative(jni::JNIEnv& env) {

View File

@@ -26,12 +26,16 @@ namespace android {
/**
* Creates a non-owning peer object (for layers currently attached to the map)
*/
CircleLayer::CircleLayer(mbgl::style::CircleLayer& coreLayer) : Layer(coreLayer) {}
CircleLayer::CircleLayer(mbgl::style::CircleLayer& coreLayer)
: Layer(coreLayer) {
}
/**
* Creates an owning peer object (for layers not attached to the map)
*/
CircleLayer::CircleLayer(std::unique_ptr<mbgl::style::CircleLayer> coreLayer) : Layer(std::move(coreLayer)) {}
CircleLayer::CircleLayer(std::unique_ptr<mbgl::style::CircleLayer> coreLayer)
: Layer(std::move(coreLayer)) {
}
CircleLayer::~CircleLayer() = default;
@@ -214,18 +218,14 @@ namespace android {
}
} // namespace
jni::Local<jni::Object<Layer>> CircleJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env,
mbgl::style::Layer& layer) {
jni::Local<jni::Object<Layer>> CircleJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, mbgl::style::Layer& layer) {
assert(layer.baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env, new CircleLayer(toCircleLayer(layer)));
}
jni::Local<jni::Object<Layer>> CircleJavaLayerPeerFactory::createJavaLayerPeer(
jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
jni::Local<jni::Object<Layer>> CircleJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
assert(layer->baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env,
new CircleLayer(std::unique_ptr<mbgl::style::CircleLayer>(
static_cast<mbgl::style::CircleLayer*>(layer.release()))));
return createJavaPeer(env, new CircleLayer(std::unique_ptr<mbgl::style::CircleLayer>(static_cast<mbgl::style::CircleLayer*>(layer.release()))));
}
void CircleJavaLayerPeerFactory::registerNative(jni::JNIEnv& env) {

View File

@@ -26,13 +26,16 @@ namespace android {
/**
* Creates a non-owning peer object (for layers currently attached to the map)
*/
FillExtrusionLayer::FillExtrusionLayer(mbgl::style::FillExtrusionLayer& coreLayer) : Layer(coreLayer) {}
FillExtrusionLayer::FillExtrusionLayer(mbgl::style::FillExtrusionLayer& coreLayer)
: Layer(coreLayer) {
}
/**
* Creates an owning peer object (for layers not attached to the map)
*/
FillExtrusionLayer::FillExtrusionLayer(std::unique_ptr<mbgl::style::FillExtrusionLayer> coreLayer)
: Layer(std::move(coreLayer)) {}
: Layer(std::move(coreLayer)) {
}
FillExtrusionLayer::~FillExtrusionLayer() = default;
@@ -169,18 +172,14 @@ namespace android {
}
} // namespace
jni::Local<jni::Object<Layer>> FillExtrusionJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env,
mbgl::style::Layer& layer) {
jni::Local<jni::Object<Layer>> FillExtrusionJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, mbgl::style::Layer& layer) {
assert(layer.baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env, new FillExtrusionLayer(toFillExtrusionLayer(layer)));
}
jni::Local<jni::Object<Layer>> FillExtrusionJavaLayerPeerFactory::createJavaLayerPeer(
jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
jni::Local<jni::Object<Layer>> FillExtrusionJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
assert(layer->baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env,
new FillExtrusionLayer(std::unique_ptr<mbgl::style::FillExtrusionLayer>(
static_cast<mbgl::style::FillExtrusionLayer*>(layer.release()))));
return createJavaPeer(env, new FillExtrusionLayer(std::unique_ptr<mbgl::style::FillExtrusionLayer>(static_cast<mbgl::style::FillExtrusionLayer*>(layer.release()))));
}
void FillExtrusionJavaLayerPeerFactory::registerNative(jni::JNIEnv& env) {
@@ -203,10 +202,8 @@ namespace android {
METHOD(&FillExtrusionLayer::getFillExtrusionColorTransition, "nativeGetFillExtrusionColorTransition"),
METHOD(&FillExtrusionLayer::setFillExtrusionColorTransition, "nativeSetFillExtrusionColorTransition"),
METHOD(&FillExtrusionLayer::getFillExtrusionColor, "nativeGetFillExtrusionColor"),
METHOD(&FillExtrusionLayer::getFillExtrusionTranslateTransition,
"nativeGetFillExtrusionTranslateTransition"),
METHOD(&FillExtrusionLayer::setFillExtrusionTranslateTransition,
"nativeSetFillExtrusionTranslateTransition"),
METHOD(&FillExtrusionLayer::getFillExtrusionTranslateTransition, "nativeGetFillExtrusionTranslateTransition"),
METHOD(&FillExtrusionLayer::setFillExtrusionTranslateTransition, "nativeSetFillExtrusionTranslateTransition"),
METHOD(&FillExtrusionLayer::getFillExtrusionTranslate, "nativeGetFillExtrusionTranslate"),
METHOD(&FillExtrusionLayer::getFillExtrusionTranslateAnchor, "nativeGetFillExtrusionTranslateAnchor"),
METHOD(&FillExtrusionLayer::getFillExtrusionPatternTransition, "nativeGetFillExtrusionPatternTransition"),

View File

@@ -26,12 +26,16 @@ namespace android {
/**
* Creates a non-owning peer object (for layers currently attached to the map)
*/
FillLayer::FillLayer(mbgl::style::FillLayer& coreLayer) : Layer(coreLayer) {}
FillLayer::FillLayer(mbgl::style::FillLayer& coreLayer)
: Layer(coreLayer) {
}
/**
* Creates an owning peer object (for layers not attached to the map)
*/
FillLayer::FillLayer(std::unique_ptr<mbgl::style::FillLayer> coreLayer) : Layer(std::move(coreLayer)) {}
FillLayer::FillLayer(std::unique_ptr<mbgl::style::FillLayer> coreLayer)
: Layer(std::move(coreLayer)) {
}
FillLayer::~FillLayer() = default;
@@ -155,18 +159,14 @@ namespace android {
}
} // namespace
jni::Local<jni::Object<Layer>> FillJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env,
mbgl::style::Layer& layer) {
jni::Local<jni::Object<Layer>> FillJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, mbgl::style::Layer& layer) {
assert(layer.baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env, new FillLayer(toFillLayer(layer)));
}
jni::Local<jni::Object<Layer>> FillJavaLayerPeerFactory::createJavaLayerPeer(
jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
jni::Local<jni::Object<Layer>> FillJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
assert(layer->baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env,
new FillLayer(std::unique_ptr<mbgl::style::FillLayer>(
static_cast<mbgl::style::FillLayer*>(layer.release()))));
return createJavaPeer(env, new FillLayer(std::unique_ptr<mbgl::style::FillLayer>(static_cast<mbgl::style::FillLayer*>(layer.release()))));
}
void FillJavaLayerPeerFactory::registerNative(jni::JNIEnv& env) {

View File

@@ -26,12 +26,16 @@ namespace android {
/**
* Creates a non-owning peer object (for layers currently attached to the map)
*/
HeatmapLayer::HeatmapLayer(mbgl::style::HeatmapLayer& coreLayer) : Layer(coreLayer) {}
HeatmapLayer::HeatmapLayer(mbgl::style::HeatmapLayer& coreLayer)
: Layer(coreLayer) {
}
/**
* Creates an owning peer object (for layers not attached to the map)
*/
HeatmapLayer::HeatmapLayer(std::unique_ptr<mbgl::style::HeatmapLayer> coreLayer) : Layer(std::move(coreLayer)) {}
HeatmapLayer::HeatmapLayer(std::unique_ptr<mbgl::style::HeatmapLayer> coreLayer)
: Layer(std::move(coreLayer)) {
}
HeatmapLayer::~HeatmapLayer() = default;
@@ -118,18 +122,14 @@ namespace android {
}
} // namespace
jni::Local<jni::Object<Layer>> HeatmapJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env,
mbgl::style::Layer& layer) {
jni::Local<jni::Object<Layer>> HeatmapJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, mbgl::style::Layer& layer) {
assert(layer.baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env, new HeatmapLayer(toHeatmapLayer(layer)));
}
jni::Local<jni::Object<Layer>> HeatmapJavaLayerPeerFactory::createJavaLayerPeer(
jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
jni::Local<jni::Object<Layer>> HeatmapJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
assert(layer->baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env,
new HeatmapLayer(std::unique_ptr<mbgl::style::HeatmapLayer>(
static_cast<mbgl::style::HeatmapLayer*>(layer.release()))));
return createJavaPeer(env, new HeatmapLayer(std::unique_ptr<mbgl::style::HeatmapLayer>(static_cast<mbgl::style::HeatmapLayer*>(layer.release()))));
}
void HeatmapJavaLayerPeerFactory::registerNative(jni::JNIEnv& env) {

View File

@@ -26,13 +26,16 @@ namespace android {
/**
* Creates a non-owning peer object (for layers currently attached to the map)
*/
HillshadeLayer::HillshadeLayer(mbgl::style::HillshadeLayer& coreLayer) : Layer(coreLayer) {}
HillshadeLayer::HillshadeLayer(mbgl::style::HillshadeLayer& coreLayer)
: Layer(coreLayer) {
}
/**
* Creates an owning peer object (for layers not attached to the map)
*/
HillshadeLayer::HillshadeLayer(std::unique_ptr<mbgl::style::HillshadeLayer> coreLayer)
: Layer(std::move(coreLayer)) {}
: Layer(std::move(coreLayer)) {
}
HillshadeLayer::~HillshadeLayer() = default;
@@ -133,18 +136,14 @@ namespace android {
}
} // namespace
jni::Local<jni::Object<Layer>> HillshadeJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env,
mbgl::style::Layer& layer) {
jni::Local<jni::Object<Layer>> HillshadeJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, mbgl::style::Layer& layer) {
assert(layer.baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env, new HillshadeLayer(toHillshadeLayer(layer)));
}
jni::Local<jni::Object<Layer>> HillshadeJavaLayerPeerFactory::createJavaLayerPeer(
jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
jni::Local<jni::Object<Layer>> HillshadeJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
assert(layer->baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env,
new HillshadeLayer(std::unique_ptr<mbgl::style::HillshadeLayer>(
static_cast<mbgl::style::HillshadeLayer*>(layer.release()))));
return createJavaPeer(env, new HillshadeLayer(std::unique_ptr<mbgl::style::HillshadeLayer>(static_cast<mbgl::style::HillshadeLayer*>(layer.release()))));
}
void HillshadeJavaLayerPeerFactory::registerNative(jni::JNIEnv& env) {

View File

@@ -5,16 +5,6 @@
#include <mbgl/style/style.hpp>
#include <mbgl/style/filter.hpp>
#include <mbgl/style/transition_options.hpp>
#include <mbgl/style/layers/background_layer.hpp>
#include <mbgl/style/layers/circle_layer.hpp>
#include <mbgl/style/layers/fill_layer.hpp>
#include <mbgl/style/layers/fill_extrusion_layer.hpp>
#include <mbgl/style/layers/heatmap_layer.hpp>
#include <mbgl/style/layers/hillshade_layer.hpp>
#include <mbgl/style/layers/line_layer.hpp>
#include <mbgl/style/layers/raster_layer.hpp>
#include <mbgl/style/layers/symbol_layer.hpp>
#include <mbgl/util/logging.hpp>
// Java -> C++ conversion

View File

@@ -20,7 +20,7 @@ namespace android {
return static_cast<mbgl::style::<%- camelize(type) %>Layer&>(layer);
}
<% if (type === 'background') { -%>
<% if (type === 'background' || type === 'location-indicator') { -%>
/**
* Creates an owning peer object (for layers not attached to the map) from the JVM side
*/
@@ -121,7 +121,7 @@ namespace android {
env,
javaClass,
"nativePtr",
<% if (type === 'background') { -%>
<% if (type === 'background' || type === 'location-indicator') { -%>
jni::MakePeer<<%- camelize(type) %>Layer, jni::String&>,
<% } else { -%>
jni::MakePeer<<%- camelize(type) %>Layer, jni::String&, jni::String&>,

View File

@@ -20,7 +20,7 @@ public:
using SuperTag = Layer;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/<%- camelize(type) %>Layer"; };
<% if (type === 'background') { -%>
<% if (type === 'background' || type === 'location-indicator') { -%>
<%- camelize(type) %>Layer(jni::JNIEnv&, jni::String&);
<% } else { -%>
<%- camelize(type) %>Layer(jni::JNIEnv&, jni::String&, jni::String&);

View File

@@ -17,6 +17,7 @@
#include "raster_layer.hpp"
#include "symbol_layer.hpp"
#include "fill_extrusion_layer.hpp"
#include "location_indicator_layer.hpp"
namespace mbgl {
@@ -73,6 +74,9 @@ LayerManagerAndroid::LayerManagerAndroid() {
#elif !defined(MBGL_LAYER_CUSTOM_DISABLE_ALL)
addLayerType(std::make_unique<CustomJavaLayerPeerFactory>());
#endif
#if !defined(MBGL_LAYER_LOCATION_INDICATOR_DISABLE_ALL)
addLayerType(std::make_unique<LocationIndicatorJavaLayerPeerFactory>());
#endif
}
LayerManagerAndroid::~LayerManagerAndroid() = default;

View File

@@ -26,12 +26,16 @@ namespace android {
/**
* Creates a non-owning peer object (for layers currently attached to the map)
*/
LineLayer::LineLayer(mbgl::style::LineLayer& coreLayer) : Layer(coreLayer) {}
LineLayer::LineLayer(mbgl::style::LineLayer& coreLayer)
: Layer(coreLayer) {
}
/**
* Creates an owning peer object (for layers not attached to the map)
*/
LineLayer::LineLayer(std::unique_ptr<mbgl::style::LineLayer> coreLayer) : Layer(std::move(coreLayer)) {}
LineLayer::LineLayer(std::unique_ptr<mbgl::style::LineLayer> coreLayer)
: Layer(std::move(coreLayer)) {
}
LineLayer::~LineLayer() = default;
@@ -247,18 +251,14 @@ namespace android {
}
} // namespace
jni::Local<jni::Object<Layer>> LineJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env,
mbgl::style::Layer& layer) {
jni::Local<jni::Object<Layer>> LineJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, mbgl::style::Layer& layer) {
assert(layer.baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env, new LineLayer(toLineLayer(layer)));
}
jni::Local<jni::Object<Layer>> LineJavaLayerPeerFactory::createJavaLayerPeer(
jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
jni::Local<jni::Object<Layer>> LineJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
assert(layer->baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env,
new LineLayer(std::unique_ptr<mbgl::style::LineLayer>(
static_cast<mbgl::style::LineLayer*>(layer.release()))));
return createJavaPeer(env, new LineLayer(std::unique_ptr<mbgl::style::LineLayer>(static_cast<mbgl::style::LineLayer*>(layer.release()))));
}
void LineJavaLayerPeerFactory::registerNative(jni::JNIEnv& env) {

View File

@@ -0,0 +1,267 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
#include "location_indicator_layer.hpp"
#include <string>
#include "../conversion/property_value.hpp"
#include "../conversion/transition_options.hpp"
#include <mbgl/style/layer_impl.hpp>
namespace mbgl {
namespace android {
inline mbgl::style::LocationIndicatorLayer& toLocationIndicatorLayer(mbgl::style::Layer& layer) {
return static_cast<mbgl::style::LocationIndicatorLayer&>(layer);
}
/**
* Creates an owning peer object (for layers not attached to the map) from the JVM side
*/
LocationIndicatorLayer::LocationIndicatorLayer(jni::JNIEnv& env, jni::String& layerId)
: Layer(std::make_unique<mbgl::style::LocationIndicatorLayer>(jni::Make<std::string>(env, layerId))) {
}
/**
* Creates a non-owning peer object (for layers currently attached to the map)
*/
LocationIndicatorLayer::LocationIndicatorLayer(mbgl::style::LocationIndicatorLayer& coreLayer)
: Layer(coreLayer) {
}
/**
* Creates an owning peer object (for layers not attached to the map)
*/
LocationIndicatorLayer::LocationIndicatorLayer(std::unique_ptr<mbgl::style::LocationIndicatorLayer> coreLayer)
: Layer(std::move(coreLayer)) {
}
LocationIndicatorLayer::~LocationIndicatorLayer() = default;
// Property getters
jni::Local<jni::Object<>> LocationIndicatorLayer::getTopImage(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
return std::move(*convert<jni::Local<jni::Object<>>>(env, toLocationIndicatorLayer(layer).getTopImage()));
}
jni::Local<jni::Object<>> LocationIndicatorLayer::getBearingImage(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
return std::move(*convert<jni::Local<jni::Object<>>>(env, toLocationIndicatorLayer(layer).getBearingImage()));
}
jni::Local<jni::Object<>> LocationIndicatorLayer::getShadowImage(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
return std::move(*convert<jni::Local<jni::Object<>>>(env, toLocationIndicatorLayer(layer).getShadowImage()));
}
jni::Local<jni::Object<>> LocationIndicatorLayer::getPerspectiveCompensation(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
return std::move(*convert<jni::Local<jni::Object<>>>(env, toLocationIndicatorLayer(layer).getPerspectiveCompensation()));
}
jni::Local<jni::Object<>> LocationIndicatorLayer::getImageTiltDisplacement(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
return std::move(*convert<jni::Local<jni::Object<>>>(env, toLocationIndicatorLayer(layer).getImageTiltDisplacement()));
}
jni::Local<jni::Object<>> LocationIndicatorLayer::getBearing(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
return std::move(*convert<jni::Local<jni::Object<>>>(env, toLocationIndicatorLayer(layer).getBearing()));
}
jni::Local<jni::Object<>> LocationIndicatorLayer::getLocation(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
return std::move(*convert<jni::Local<jni::Object<>>>(env, toLocationIndicatorLayer(layer).getLocation()));
}
jni::Local<jni::Object<TransitionOptions>> LocationIndicatorLayer::getLocationTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = toLocationIndicatorLayer(layer).getLocationTransition();
return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void LocationIndicatorLayer::setLocationTransition(jni::JNIEnv&, jlong duration, jlong delay) {
mbgl::style::TransitionOptions options;
options.duration.emplace(mbgl::Milliseconds(duration));
options.delay.emplace(mbgl::Milliseconds(delay));
toLocationIndicatorLayer(layer).setLocationTransition(options);
}
jni::Local<jni::Object<>> LocationIndicatorLayer::getAccuracyRadius(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
return std::move(*convert<jni::Local<jni::Object<>>>(env, toLocationIndicatorLayer(layer).getAccuracyRadius()));
}
jni::Local<jni::Object<TransitionOptions>> LocationIndicatorLayer::getAccuracyRadiusTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = toLocationIndicatorLayer(layer).getAccuracyRadiusTransition();
return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void LocationIndicatorLayer::setAccuracyRadiusTransition(jni::JNIEnv&, jlong duration, jlong delay) {
mbgl::style::TransitionOptions options;
options.duration.emplace(mbgl::Milliseconds(duration));
options.delay.emplace(mbgl::Milliseconds(delay));
toLocationIndicatorLayer(layer).setAccuracyRadiusTransition(options);
}
jni::Local<jni::Object<>> LocationIndicatorLayer::getTopImageSize(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
return std::move(*convert<jni::Local<jni::Object<>>>(env, toLocationIndicatorLayer(layer).getTopImageSize()));
}
jni::Local<jni::Object<TransitionOptions>> LocationIndicatorLayer::getTopImageSizeTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = toLocationIndicatorLayer(layer).getTopImageSizeTransition();
return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void LocationIndicatorLayer::setTopImageSizeTransition(jni::JNIEnv&, jlong duration, jlong delay) {
mbgl::style::TransitionOptions options;
options.duration.emplace(mbgl::Milliseconds(duration));
options.delay.emplace(mbgl::Milliseconds(delay));
toLocationIndicatorLayer(layer).setTopImageSizeTransition(options);
}
jni::Local<jni::Object<>> LocationIndicatorLayer::getBearingImageSize(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
return std::move(*convert<jni::Local<jni::Object<>>>(env, toLocationIndicatorLayer(layer).getBearingImageSize()));
}
jni::Local<jni::Object<TransitionOptions>> LocationIndicatorLayer::getBearingImageSizeTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = toLocationIndicatorLayer(layer).getBearingImageSizeTransition();
return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void LocationIndicatorLayer::setBearingImageSizeTransition(jni::JNIEnv&, jlong duration, jlong delay) {
mbgl::style::TransitionOptions options;
options.duration.emplace(mbgl::Milliseconds(duration));
options.delay.emplace(mbgl::Milliseconds(delay));
toLocationIndicatorLayer(layer).setBearingImageSizeTransition(options);
}
jni::Local<jni::Object<>> LocationIndicatorLayer::getShadowImageSize(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
return std::move(*convert<jni::Local<jni::Object<>>>(env, toLocationIndicatorLayer(layer).getShadowImageSize()));
}
jni::Local<jni::Object<TransitionOptions>> LocationIndicatorLayer::getShadowImageSizeTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = toLocationIndicatorLayer(layer).getShadowImageSizeTransition();
return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void LocationIndicatorLayer::setShadowImageSizeTransition(jni::JNIEnv&, jlong duration, jlong delay) {
mbgl::style::TransitionOptions options;
options.duration.emplace(mbgl::Milliseconds(duration));
options.delay.emplace(mbgl::Milliseconds(delay));
toLocationIndicatorLayer(layer).setShadowImageSizeTransition(options);
}
jni::Local<jni::Object<>> LocationIndicatorLayer::getAccuracyRadiusColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
return std::move(*convert<jni::Local<jni::Object<>>>(env, toLocationIndicatorLayer(layer).getAccuracyRadiusColor()));
}
jni::Local<jni::Object<TransitionOptions>> LocationIndicatorLayer::getAccuracyRadiusColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = toLocationIndicatorLayer(layer).getAccuracyRadiusColorTransition();
return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void LocationIndicatorLayer::setAccuracyRadiusColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
mbgl::style::TransitionOptions options;
options.duration.emplace(mbgl::Milliseconds(duration));
options.delay.emplace(mbgl::Milliseconds(delay));
toLocationIndicatorLayer(layer).setAccuracyRadiusColorTransition(options);
}
jni::Local<jni::Object<>> LocationIndicatorLayer::getAccuracyRadiusBorderColor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
return std::move(*convert<jni::Local<jni::Object<>>>(env, toLocationIndicatorLayer(layer).getAccuracyRadiusBorderColor()));
}
jni::Local<jni::Object<TransitionOptions>> LocationIndicatorLayer::getAccuracyRadiusBorderColorTransition(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
mbgl::style::TransitionOptions options = toLocationIndicatorLayer(layer).getAccuracyRadiusBorderColorTransition();
return std::move(*convert<jni::Local<jni::Object<TransitionOptions>>>(env, options));
}
void LocationIndicatorLayer::setAccuracyRadiusBorderColorTransition(jni::JNIEnv&, jlong duration, jlong delay) {
mbgl::style::TransitionOptions options;
options.duration.emplace(mbgl::Milliseconds(duration));
options.delay.emplace(mbgl::Milliseconds(delay));
toLocationIndicatorLayer(layer).setAccuracyRadiusBorderColorTransition(options);
}
// LocationIndicatorJavaLayerPeerFactory
LocationIndicatorJavaLayerPeerFactory::~LocationIndicatorJavaLayerPeerFactory() = default;
namespace {
jni::Local<jni::Object<Layer>> createJavaPeer(jni::JNIEnv& env, Layer* layer) {
static auto& javaClass = jni::Class<LocationIndicatorLayer>::Singleton(env);
static auto constructor = javaClass.GetConstructor<jni::jlong>(env);
return javaClass.New(env, constructor, reinterpret_cast<jni::jlong>(layer));
}
} // namespace
jni::Local<jni::Object<Layer>> LocationIndicatorJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, mbgl::style::Layer& layer) {
assert(layer.baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env, new LocationIndicatorLayer(toLocationIndicatorLayer(layer)));
}
jni::Local<jni::Object<Layer>> LocationIndicatorJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
assert(layer->baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env, new LocationIndicatorLayer(std::unique_ptr<mbgl::style::LocationIndicatorLayer>(static_cast<mbgl::style::LocationIndicatorLayer*>(layer.release()))));
}
void LocationIndicatorJavaLayerPeerFactory::registerNative(jni::JNIEnv& env) {
// Lookup the class
static auto& javaClass = jni::Class<LocationIndicatorLayer>::Singleton(env);
#define METHOD(MethodPtr, name) jni::MakeNativePeerMethod<decltype(MethodPtr), (MethodPtr)>(name)
// Register the peer
jni::RegisterNativePeer<LocationIndicatorLayer>(
env,
javaClass,
"nativePtr",
jni::MakePeer<LocationIndicatorLayer, jni::String&>,
"initialize",
"finalize",
METHOD(&LocationIndicatorLayer::getTopImage, "nativeGetTopImage"),
METHOD(&LocationIndicatorLayer::getBearingImage, "nativeGetBearingImage"),
METHOD(&LocationIndicatorLayer::getShadowImage, "nativeGetShadowImage"),
METHOD(&LocationIndicatorLayer::getPerspectiveCompensation, "nativeGetPerspectiveCompensation"),
METHOD(&LocationIndicatorLayer::getImageTiltDisplacement, "nativeGetImageTiltDisplacement"),
METHOD(&LocationIndicatorLayer::getBearing, "nativeGetBearing"),
METHOD(&LocationIndicatorLayer::getLocationTransition, "nativeGetLocationTransition"),
METHOD(&LocationIndicatorLayer::setLocationTransition, "nativeSetLocationTransition"),
METHOD(&LocationIndicatorLayer::getLocation, "nativeGetLocation"),
METHOD(&LocationIndicatorLayer::getAccuracyRadiusTransition, "nativeGetAccuracyRadiusTransition"),
METHOD(&LocationIndicatorLayer::setAccuracyRadiusTransition, "nativeSetAccuracyRadiusTransition"),
METHOD(&LocationIndicatorLayer::getAccuracyRadius, "nativeGetAccuracyRadius"),
METHOD(&LocationIndicatorLayer::getTopImageSizeTransition, "nativeGetTopImageSizeTransition"),
METHOD(&LocationIndicatorLayer::setTopImageSizeTransition, "nativeSetTopImageSizeTransition"),
METHOD(&LocationIndicatorLayer::getTopImageSize, "nativeGetTopImageSize"),
METHOD(&LocationIndicatorLayer::getBearingImageSizeTransition, "nativeGetBearingImageSizeTransition"),
METHOD(&LocationIndicatorLayer::setBearingImageSizeTransition, "nativeSetBearingImageSizeTransition"),
METHOD(&LocationIndicatorLayer::getBearingImageSize, "nativeGetBearingImageSize"),
METHOD(&LocationIndicatorLayer::getShadowImageSizeTransition, "nativeGetShadowImageSizeTransition"),
METHOD(&LocationIndicatorLayer::setShadowImageSizeTransition, "nativeSetShadowImageSizeTransition"),
METHOD(&LocationIndicatorLayer::getShadowImageSize, "nativeGetShadowImageSize"),
METHOD(&LocationIndicatorLayer::getAccuracyRadiusColorTransition, "nativeGetAccuracyRadiusColorTransition"),
METHOD(&LocationIndicatorLayer::setAccuracyRadiusColorTransition, "nativeSetAccuracyRadiusColorTransition"),
METHOD(&LocationIndicatorLayer::getAccuracyRadiusColor, "nativeGetAccuracyRadiusColor"),
METHOD(&LocationIndicatorLayer::getAccuracyRadiusBorderColorTransition, "nativeGetAccuracyRadiusBorderColorTransition"),
METHOD(&LocationIndicatorLayer::setAccuracyRadiusBorderColorTransition, "nativeSetAccuracyRadiusBorderColorTransition"),
METHOD(&LocationIndicatorLayer::getAccuracyRadiusBorderColor, "nativeGetAccuracyRadiusBorderColor"));
}
} // namespace android
} // namespace mbgl

View File

@@ -0,0 +1,86 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
#pragma once
#include "layer.hpp"
#include "../transition_options.hpp"
#include <mbgl/layermanager/location_indicator_layer_factory.hpp>
#include <mbgl/style/layers/location_indicator_layer.hpp>
#include <jni/jni.hpp>
namespace mbgl {
namespace android {
class LocationIndicatorLayer : public Layer {
public:
using SuperTag = Layer;
static constexpr auto Name() { return "com/mapbox/mapboxsdk/style/layers/LocationIndicatorLayer"; };
LocationIndicatorLayer(jni::JNIEnv&, jni::String&);
LocationIndicatorLayer(mbgl::style::LocationIndicatorLayer&);
LocationIndicatorLayer(std::unique_ptr<mbgl::style::LocationIndicatorLayer>);
~LocationIndicatorLayer();
// Properties
jni::Local<jni::Object<jni::ObjectTag>> getTopImage(jni::JNIEnv&);
jni::Local<jni::Object<jni::ObjectTag>> getBearingImage(jni::JNIEnv&);
jni::Local<jni::Object<jni::ObjectTag>> getShadowImage(jni::JNIEnv&);
jni::Local<jni::Object<jni::ObjectTag>> getPerspectiveCompensation(jni::JNIEnv&);
jni::Local<jni::Object<jni::ObjectTag>> getImageTiltDisplacement(jni::JNIEnv&);
jni::Local<jni::Object<jni::ObjectTag>> getBearing(jni::JNIEnv&);
jni::Local<jni::Object<jni::ObjectTag>> getLocation(jni::JNIEnv&);
void setLocationTransition(jni::JNIEnv&, jlong duration, jlong delay);
jni::Local<jni::Object<TransitionOptions>> getLocationTransition(jni::JNIEnv&);
jni::Local<jni::Object<jni::ObjectTag>> getAccuracyRadius(jni::JNIEnv&);
void setAccuracyRadiusTransition(jni::JNIEnv&, jlong duration, jlong delay);
jni::Local<jni::Object<TransitionOptions>> getAccuracyRadiusTransition(jni::JNIEnv&);
jni::Local<jni::Object<jni::ObjectTag>> getTopImageSize(jni::JNIEnv&);
void setTopImageSizeTransition(jni::JNIEnv&, jlong duration, jlong delay);
jni::Local<jni::Object<TransitionOptions>> getTopImageSizeTransition(jni::JNIEnv&);
jni::Local<jni::Object<jni::ObjectTag>> getBearingImageSize(jni::JNIEnv&);
void setBearingImageSizeTransition(jni::JNIEnv&, jlong duration, jlong delay);
jni::Local<jni::Object<TransitionOptions>> getBearingImageSizeTransition(jni::JNIEnv&);
jni::Local<jni::Object<jni::ObjectTag>> getShadowImageSize(jni::JNIEnv&);
void setShadowImageSizeTransition(jni::JNIEnv&, jlong duration, jlong delay);
jni::Local<jni::Object<TransitionOptions>> getShadowImageSizeTransition(jni::JNIEnv&);
jni::Local<jni::Object<jni::ObjectTag>> getAccuracyRadiusColor(jni::JNIEnv&);
void setAccuracyRadiusColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
jni::Local<jni::Object<TransitionOptions>> getAccuracyRadiusColorTransition(jni::JNIEnv&);
jni::Local<jni::Object<jni::ObjectTag>> getAccuracyRadiusBorderColor(jni::JNIEnv&);
void setAccuracyRadiusBorderColorTransition(jni::JNIEnv&, jlong duration, jlong delay);
jni::Local<jni::Object<TransitionOptions>> getAccuracyRadiusBorderColorTransition(jni::JNIEnv&);
}; // class LocationIndicatorLayer
class LocationIndicatorJavaLayerPeerFactory final : public JavaLayerPeerFactory, public mbgl::LocationIndicatorLayerFactory {
public:
~LocationIndicatorJavaLayerPeerFactory() override;
// JavaLayerPeerFactory overrides.
jni::Local<jni::Object<Layer>> createJavaLayerPeer(jni::JNIEnv&, mbgl::style::Layer&) final;
jni::Local<jni::Object<Layer>> createJavaLayerPeer(jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer>) final;
void registerNative(jni::JNIEnv&) final;
LayerFactory* getLayerFactory() final { return this; }
}; // class LocationIndicatorJavaLayerPeerFactory
} // namespace android
} // namespace mbgl

View File

@@ -26,12 +26,16 @@ namespace android {
/**
* Creates a non-owning peer object (for layers currently attached to the map)
*/
RasterLayer::RasterLayer(mbgl::style::RasterLayer& coreLayer) : Layer(coreLayer) {}
RasterLayer::RasterLayer(mbgl::style::RasterLayer& coreLayer)
: Layer(coreLayer) {
}
/**
* Creates an owning peer object (for layers not attached to the map)
*/
RasterLayer::RasterLayer(std::unique_ptr<mbgl::style::RasterLayer> coreLayer) : Layer(std::move(coreLayer)) {}
RasterLayer::RasterLayer(std::unique_ptr<mbgl::style::RasterLayer> coreLayer)
: Layer(std::move(coreLayer)) {
}
RasterLayer::~RasterLayer() = default;
@@ -168,18 +172,14 @@ namespace android {
}
} // namespace
jni::Local<jni::Object<Layer>> RasterJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env,
mbgl::style::Layer& layer) {
jni::Local<jni::Object<Layer>> RasterJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, mbgl::style::Layer& layer) {
assert(layer.baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env, new RasterLayer(toRasterLayer(layer)));
}
jni::Local<jni::Object<Layer>> RasterJavaLayerPeerFactory::createJavaLayerPeer(
jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
jni::Local<jni::Object<Layer>> RasterJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
assert(layer->baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env,
new RasterLayer(std::unique_ptr<mbgl::style::RasterLayer>(
static_cast<mbgl::style::RasterLayer*>(layer.release()))));
return createJavaPeer(env, new RasterLayer(std::unique_ptr<mbgl::style::RasterLayer>(static_cast<mbgl::style::RasterLayer*>(layer.release()))));
}
void RasterJavaLayerPeerFactory::registerNative(jni::JNIEnv& env) {

View File

@@ -26,12 +26,16 @@ namespace android {
/**
* Creates a non-owning peer object (for layers currently attached to the map)
*/
SymbolLayer::SymbolLayer(mbgl::style::SymbolLayer& coreLayer) : Layer(coreLayer) {}
SymbolLayer::SymbolLayer(mbgl::style::SymbolLayer& coreLayer)
: Layer(coreLayer) {
}
/**
* Creates an owning peer object (for layers not attached to the map)
*/
SymbolLayer::SymbolLayer(std::unique_ptr<mbgl::style::SymbolLayer> coreLayer) : Layer(std::move(coreLayer)) {}
SymbolLayer::SymbolLayer(std::unique_ptr<mbgl::style::SymbolLayer> coreLayer)
: Layer(std::move(coreLayer)) {
}
SymbolLayer::~SymbolLayer() = default;
@@ -481,18 +485,14 @@ namespace android {
}
} // namespace
jni::Local<jni::Object<Layer>> SymbolJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env,
mbgl::style::Layer& layer) {
jni::Local<jni::Object<Layer>> SymbolJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, mbgl::style::Layer& layer) {
assert(layer.baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env, new SymbolLayer(toSymbolLayer(layer)));
}
jni::Local<jni::Object<Layer>> SymbolJavaLayerPeerFactory::createJavaLayerPeer(
jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
jni::Local<jni::Object<Layer>> SymbolJavaLayerPeerFactory::createJavaLayerPeer(jni::JNIEnv& env, std::unique_ptr<mbgl::style::Layer> layer) {
assert(layer->baseImpl->getTypeInfo() == getTypeInfo());
return createJavaPeer(env,
new SymbolLayer(std::unique_ptr<mbgl::style::SymbolLayer>(
static_cast<mbgl::style::SymbolLayer*>(layer.release()))));
return createJavaPeer(env, new SymbolLayer(std::unique_ptr<mbgl::style::SymbolLayer>(static_cast<mbgl::style::SymbolLayer*>(layer.release()))));
}
void SymbolJavaLayerPeerFactory::registerNative(jni::JNIEnv& env) {

View File

@@ -0,0 +1,211 @@
package com.mapbox.mapboxsdk.location;
import android.graphics.Bitmap;
import androidx.annotation.Nullable;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.location.modes.RenderMode;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.LocationIndicatorLayer;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.utils.BitmapUtils;
import com.mapbox.mapboxsdk.utils.ColorUtils;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BEARING_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BEARING_STALE_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.SHADOW_ICON;
import static com.mapbox.mapboxsdk.style.expressions.Expression.rgba;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
class IndicatorLocationLayerRenderer implements LocationLayerRenderer {
private Style style;
private final LayerSourceProvider layerSourceProvider;
private LocationIndicatorLayer layer;
@Nullable
private LatLng latLng;
IndicatorLocationLayerRenderer(Style style,
LayerSourceProvider layerSourceProvider) {
this.style = style;
this.layerSourceProvider = layerSourceProvider;
}
@Override
public void initializeComponents(Style style) {
this.style = style;
}
@Override
public void addLayers(LocationComponentPositionManager positionManager) {
layer = layerSourceProvider.generateLocationComponentLayer();
setLayerLocation(latLng);
positionManager.addLayerToMap(layer);
}
@Override
public void removeLayers() {
style.removeLayer(layer);
}
@Override
public void hide() {
setLayerVisibility(false);
}
@Override
public void cameraTiltUpdated(double tilt) {
// ignored
}
@Override
public void cameraBearingUpdated(double bearing) {
// ignored
}
@Override
public void show(@RenderMode.Mode int renderMode, boolean isStale) {
setImages(renderMode, isStale);
setLayerVisibility(true);
}
@Override
public void styleAccuracy(float accuracyAlpha, int accuracyColor) {
float[] colorArray = ColorUtils.colorToRgbaArray(accuracyColor);
colorArray[3] = accuracyAlpha;
Expression rgbaExpression = rgba(colorArray[0], colorArray[1], colorArray[2], colorArray[3]);
layer.setProperties(
PropertyFactory.accuracyRadiusColor(rgbaExpression),
PropertyFactory.accuracyRadiusBorderColor(rgbaExpression)
);
}
@Override
public void setLatLng(LatLng latLng) {
setLayerLocation(latLng);
}
@Override
public void setGpsBearing(Float gpsBearing) {
setLayerBearing(gpsBearing);
}
@Override
public void setCompassBearing(Float compassBearing) {
setLayerBearing(compassBearing);
}
@Override
public void setAccuracyRadius(Float accuracy) {
layer.setProperties(
PropertyFactory.accuracyRadius(accuracy)
);
}
@Override
public void styleScaling(Expression scaleExpression) {
layer.setProperties(
PropertyFactory.shadowImageSize(scaleExpression),
PropertyFactory.bearingImageSize(scaleExpression),
PropertyFactory.topImageSize(scaleExpression)
);
}
@Override
public void setLocationStale(boolean isStale, int renderMode) {
setImages(renderMode, isStale);
}
@Override
public void updateIconIds(String foregroundIconString, String foregroundStaleIconString, String backgroundIconString,
String backgroundStaleIconString, String bearingIconString) {
// not supported
}
@Override
public void addBitmaps(@RenderMode.Mode int renderMode, @Nullable Bitmap shadowBitmap, Bitmap backgroundBitmap,
Bitmap backgroundStaleBitmap, Bitmap bearingBitmap,
Bitmap foregroundBitmap, Bitmap foregroundStaleBitmap) {
if (shadowBitmap != null) {
style.addImage(SHADOW_ICON, shadowBitmap);
} else {
style.removeImage(SHADOW_ICON);
}
style.addImage(FOREGROUND_ICON, foregroundBitmap);
style.addImage(FOREGROUND_STALE_ICON, foregroundStaleBitmap);
if (renderMode == RenderMode.COMPASS) {
float leftOffset = (bearingBitmap.getWidth() - backgroundBitmap.getWidth()) / 2f;
float topOffset = (bearingBitmap.getHeight() - backgroundBitmap.getHeight()) / 2f;
style.addImage(BEARING_ICON, BitmapUtils.mergeBitmap(bearingBitmap, backgroundBitmap, leftOffset, topOffset));
float staleLeftOffset = (bearingBitmap.getWidth() - backgroundStaleBitmap.getWidth()) / 2f;
float staleTopOffset = (bearingBitmap.getHeight() - backgroundStaleBitmap.getHeight()) / 2f;
style.addImage(BEARING_STALE_ICON,
BitmapUtils.mergeBitmap(bearingBitmap, backgroundStaleBitmap, staleLeftOffset, staleTopOffset));
} else {
style.addImage(BACKGROUND_ICON, backgroundBitmap);
style.addImage(BACKGROUND_STALE_ICON, backgroundStaleBitmap);
style.addImage(BEARING_ICON, bearingBitmap);
}
}
private void setLayerVisibility(boolean visible) {
layer.setProperties(visibility(visible ? VISIBLE : NONE));
}
private void setLayerLocation(@Nullable LatLng latLng) {
this.latLng = latLng;
if (latLng != null) {
Double[] values = new Double[] {latLng.getLatitude(), latLng.getLongitude(), 0d};
layer.setProperties(
PropertyFactory.location(values)
);
}
}
private void setLayerBearing(double bearing) {
layer.setProperties(
PropertyFactory.bearing(bearing)
);
}
private void setImages(@RenderMode.Mode int renderMode, boolean isStale) {
String topImage = "";
String bearingImage = "";
String shadowImage = "";
switch (renderMode) {
case RenderMode.COMPASS:
topImage = isStale ? FOREGROUND_STALE_ICON : FOREGROUND_ICON;
bearingImage = isStale ? BEARING_STALE_ICON : BEARING_ICON;
shadowImage = SHADOW_ICON;
break;
case RenderMode.GPS:
topImage = "";
bearingImage = isStale ? FOREGROUND_STALE_ICON : FOREGROUND_ICON;
shadowImage = "";
setAccuracyRadius(0f);
break;
case RenderMode.NORMAL:
topImage = isStale ? FOREGROUND_STALE_ICON : FOREGROUND_ICON;
bearingImage = isStale ? BACKGROUND_STALE_ICON : BACKGROUND_ICON;
shadowImage = SHADOW_ICON;
break;
}
layer.setProperties(
PropertyFactory.topImage(topImage),
PropertyFactory.bearingImage(bearingImage),
PropertyFactory.shadowImage(shadowImage)
);
}
}

View File

@@ -13,14 +13,14 @@ import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_
class LayerFeatureProvider {
@NonNull
Feature generateLocationFeature(@Nullable Feature locationFeature, @NonNull LocationComponentOptions options) {
Feature generateLocationFeature(@Nullable Feature locationFeature, boolean isStale) {
if (locationFeature != null) {
return locationFeature;
}
locationFeature = Feature.fromGeometry(Point.fromLngLat(0.0, 0.0));
locationFeature.addNumberProperty(PROPERTY_GPS_BEARING, 0f);
locationFeature.addNumberProperty(PROPERTY_COMPASS_BEARING, 0f);
locationFeature.addBooleanProperty(PROPERTY_LOCATION_STALE, options.enableStaleState());
locationFeature.addBooleanProperty(PROPERTY_LOCATION_STALE, isStale);
return locationFeature;
}
}

View File

@@ -1,14 +1,20 @@
package com.mapbox.mapboxsdk.location;
import androidx.annotation.NonNull;
import com.mapbox.geojson.Feature;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.LocationIndicatorLayer;
import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.PropertyFactory;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import java.util.HashSet;
import java.util.Set;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.ACCURACY_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BEARING_LAYER;
@@ -108,4 +114,17 @@ class LayerSourceProvider {
circlePitchAlignment(Property.CIRCLE_PITCH_ALIGNMENT_MAP)
);
}
Set<String> getEmptyLayerSet() {
return new HashSet<>();
}
LocationIndicatorLayer generateLocationComponentLayer() {
LocationIndicatorLayer layer = new LocationIndicatorLayer(FOREGROUND_LAYER);
layer.setProperties(
PropertyFactory.perspectiveCompensation(0.9f),
PropertyFactory.imageTiltDisplacement(4f)
);
return layer;
}
}

View File

@@ -140,6 +140,12 @@ public final class LocationComponent {
*/
private boolean isComponentInitialized;
/**
* Indicates whether we're using the {@link com.mapbox.mapboxsdk.style.layers.LocationIndicatorLayer}
* or the stack of {@link com.mapbox.mapboxsdk.style.layers.SymbolLayer}s.
*/
private boolean useSpecializedLocationLayer;
/**
* Indicates that the component is enabled and should be displaying location if Mapbox components are available and
* the lifecycle is in a started state.
@@ -341,7 +347,7 @@ public final class LocationComponent {
@Deprecated
public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
@NonNull LocationComponentOptions options) {
initialize(context, style, options);
initialize(context, style, false, options);
initializeLocationEngine(context);
applyStyle(options);
}
@@ -425,7 +431,7 @@ public final class LocationComponent {
public void activateLocationComponent(@NonNull Context context, @NonNull Style style,
@Nullable LocationEngine locationEngine,
@NonNull LocationComponentOptions options) {
initialize(context, style, options);
initialize(context, style, false, options);
setLocationEngine(locationEngine);
applyStyle(options);
}
@@ -446,7 +452,7 @@ public final class LocationComponent {
@Nullable LocationEngine locationEngine,
@NonNull LocationEngineRequest locationEngineRequest,
@NonNull LocationComponentOptions options) {
initialize(context, style, options);
initialize(context, style, false, options);
setLocationEngineRequest(locationEngineRequest);
setLocationEngine(locationEngine);
applyStyle(options);
@@ -470,7 +476,8 @@ public final class LocationComponent {
// Initialize the LocationComponent with Context, the map's `Style`, and either custom LocationComponentOptions
// or backup options created from default/custom attributes
initialize(activationOptions.context(), activationOptions.style(), options);
initialize(activationOptions.context(), activationOptions.style(),
activationOptions.useSpecializedLocationLayer(), options);
// Apply the LocationComponent styling
// TODO avoid doubling style initialization
@@ -1255,7 +1262,7 @@ public final class LocationComponent {
mapboxMap.removeOnCameraIdleListener(onCameraIdleListener);
}
private void initialize(@NonNull final Context context, @NonNull Style style,
private void initialize(@NonNull final Context context, @NonNull Style style, boolean useSpecializedLocationLayer,
@NonNull final LocationComponentOptions options) {
if (isComponentInitialized) {
return;
@@ -1268,6 +1275,7 @@ public final class LocationComponent {
this.style = style;
this.options = options;
this.useSpecializedLocationLayer = useSpecializedLocationLayer;
mapboxMap.addOnMapClickListener(onMapClickListener);
mapboxMap.addOnMapLongClickListener(onMapLongClickListener);
@@ -1276,7 +1284,7 @@ public final class LocationComponent {
LayerFeatureProvider featureProvider = new LayerFeatureProvider();
LayerBitmapProvider bitmapProvider = new LayerBitmapProvider(context);
locationLayerController = new LocationLayerController(mapboxMap, style, sourceProvider, featureProvider,
bitmapProvider, options, renderModeChangedListener);
bitmapProvider, options, renderModeChangedListener, useSpecializedLocationLayer);
locationCameraController = new LocationCameraController(
context, mapboxMap, transform, cameraTrackingChangedListener, options, onCameraMoveInvalidateListener);
@@ -1446,20 +1454,24 @@ public final class LocationComponent {
@SuppressLint("MissingPermission")
private void updateLayerOffsets(boolean forceUpdate) {
if (useSpecializedLocationLayer) {
return;
}
CameraPosition position = mapboxMap.getCameraPosition();
if (lastCameraPosition == null || forceUpdate) {
lastCameraPosition = position;
locationLayerController.updateForegroundBearing((float) position.bearing);
locationLayerController.updateForegroundOffset(position.tilt);
locationLayerController.cameraBearingUpdated(position.bearing);
locationLayerController.cameraTiltUpdated(position.tilt);
updateAccuracyRadius(getLastKnownLocation(), true);
return;
}
if (position.bearing != lastCameraPosition.bearing) {
locationLayerController.updateForegroundBearing((float) position.bearing);
locationLayerController.cameraBearingUpdated(position.bearing);
}
if (position.tilt != lastCameraPosition.tilt) {
locationLayerController.updateForegroundOffset(position.tilt);
locationLayerController.cameraTiltUpdated(position.tilt);
}
if (position.zoom != lastCameraPosition.zoom) {
updateAccuracyRadius(getLastKnownLocation(), true);
@@ -1468,7 +1480,15 @@ public final class LocationComponent {
}
private void updateAccuracyRadius(Location location, boolean noAnimation) {
locationAnimatorCoordinator.feedNewAccuracyRadius(Utils.calculateZoomLevelRadius(mapboxMap, location), noAnimation);
float radius;
if (location == null) {
radius = 0;
} else if (useSpecializedLocationLayer) {
radius = location.getAccuracy();
} else {
radius = Utils.calculateZoomLevelRadius(mapboxMap, location);
}
locationAnimatorCoordinator.feedNewAccuracyRadius(radius, noAnimation);
}
private void updateAnimatorListenerHolders() {

View File

@@ -1,6 +1,7 @@
package com.mapbox.mapboxsdk.location;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -21,13 +22,15 @@ public class LocationComponentActivationOptions {
private final LocationComponentOptions locationComponentOptions;
private final int styleRes;
private final boolean useDefaultLocationEngine;
private final boolean useSpecializedLocationLayer;
private LocationComponentActivationOptions(@NonNull Context context, @NonNull Style style,
@Nullable LocationEngine locationEngine,
@Nullable LocationEngineRequest locationEngineRequest,
@Nullable LocationComponentOptions locationComponentOptions,
int styleRes,
boolean useDefaultLocationEngine) {
boolean useDefaultLocationEngine,
boolean useSpecializedLocationLayer) {
this.context = context;
this.style = style;
this.locationEngine = locationEngine;
@@ -35,6 +38,7 @@ public class LocationComponentActivationOptions {
this.locationComponentOptions = locationComponentOptions;
this.styleRes = styleRes;
this.useDefaultLocationEngine = useDefaultLocationEngine;
this.useSpecializedLocationLayer = useSpecializedLocationLayer;
}
/**
@@ -116,6 +120,25 @@ public class LocationComponentActivationOptions {
return useDefaultLocationEngine;
}
/**
* True if you want to initialize and use the specialized location layer to render the location puck.
* <p>
* The specialized layer comes with significant performance improvements,
* but since it's not based on the runtime styling,
* it's not fully compatible with the traditional implementation. The incompatibilities are:
* <ul>
* <li> Constants like {@link LocationComponentConstants#FOREGROUND_LAYER}
* or {@link LocationComponentConstants#LOCATION_SOURCE} are ignored.
* <li> All options that alter the image ID, like {@link LocationComponentOptions#foregroundName()}, are ignored.
* Use {@link LocationComponentOptions#foregroundDrawable()} instead.
* </ul>
*
* @return whether the default specialized location layer is used
*/
public boolean useSpecializedLocationLayer() {
return useSpecializedLocationLayer;
}
/**
* Builder class for constructing a new instance of {@link LocationComponentActivationOptions}.
*/
@@ -136,6 +159,8 @@ public class LocationComponentActivationOptions {
*/
private boolean useDefaultLocationEngine = true;
private boolean useSpecializedLocationLayer = false;
/**
* Constructor for the {@link LocationComponentActivationOptions} builder class.
* While other activation options are optional, the activation process always requires
@@ -208,6 +233,28 @@ public class LocationComponentActivationOptions {
return this;
}
/**
* True if you want to initialize and use the specialized location layer to render the location puck.
* <p>
* The specialized layer comes with significant performance improvements,
* but since it's not based on the runtime styling,
* it's not fully compatible with the traditional implementation. The incompatibilities are:
* <ul>
* <li> Constants like {@link LocationComponentConstants#FOREGROUND_LAYER}
* or {@link LocationComponentConstants#LOCATION_SOURCE} are ignored.
* <li> All options that alter the image ID, like {@link LocationComponentOptions#foregroundName()}, are ignored.
* Use {@link LocationComponentOptions#foregroundDrawable()} instead.
* </ul>
*
* @param useSpecializedLocationLayer true if you want to initialize and use the
* specialized location layer. Defaults to false.
* @return the {@link Builder} object being constructed
*/
public Builder useSpecializedLocationLayer(boolean useSpecializedLocationLayer) {
this.useSpecializedLocationLayer = useSpecializedLocationLayer;
return this;
}
/**
* Method which actually builds the {@link LocationComponentActivationOptions} object while
* taking the various options into account.
@@ -217,28 +264,29 @@ public class LocationComponentActivationOptions {
public LocationComponentActivationOptions build() {
if (styleRes != 0 && locationComponentOptions != null) {
throw new IllegalArgumentException(
"You've provided both a style resource and a LocationComponentOptions object to the "
+ "LocationComponentActivationOptions builder. You can't use both and "
+ "you must choose one of the two to style the LocationComponent.");
"You've provided both a style resource and a LocationComponentOptions object to the "
+ "LocationComponentActivationOptions builder. You can't use both and "
+ "you must choose one of the two to style the LocationComponent.");
}
if (context == null) {
throw new NullPointerException(
"Context in LocationComponentActivationOptions is null.");
"Context in LocationComponentActivationOptions is null.");
}
if (style == null) {
throw new NullPointerException(
"Style in LocationComponentActivationOptions is null. Make sure the "
+ "Style object isn't null. Wait for the map to fully load before passing "
+ "the Style object to LocationComponentActivationOptions.");
"Style in LocationComponentActivationOptions is null. Make sure the "
+ "Style object isn't null. Wait for the map to fully load before passing "
+ "the Style object to LocationComponentActivationOptions.");
}
if (!style.isFullyLoaded()) {
throw new IllegalArgumentException(
"Style in LocationComponentActivationOptions isn't fully loaded. Wait for the "
+ "map to fully load before passing the Style object to "
+ "LocationComponentActivationOptions.");
"Style in LocationComponentActivationOptions isn't fully loaded. Wait for the "
+ "map to fully load before passing the Style object to "
+ "LocationComponentActivationOptions.");
}
return new LocationComponentActivationOptions(context, style, locationEngine,
locationEngineRequest, locationComponentOptions, styleRes, useDefaultLocationEngine);
locationEngineRequest, locationComponentOptions, styleRes, useDefaultLocationEngine,
useSpecializedLocationLayer);
}
}
}

View File

@@ -87,6 +87,7 @@ public final class LocationComponentConstants {
static final String BACKGROUND_STALE_ICON = "mapbox-location-background-stale-icon";
static final String SHADOW_ICON = "mapbox-location-shadow-icon";
static final String BEARING_ICON = "mapbox-location-bearing-icon";
static final String BEARING_STALE_ICON = "mapbox-location-bearing-stale-icon";
private LocationComponentConstants() {
// Class should not be initialized

View File

@@ -2,28 +2,22 @@ package com.mapbox.mapboxsdk.location;
import android.graphics.Bitmap;
import android.graphics.PointF;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.location.modes.RenderMode;
import com.mapbox.mapboxsdk.log.Logger;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.ACCURACY_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_STALE_ICON;
@@ -32,71 +26,58 @@ import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BEARING_L
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.LOCATION_SOURCE;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_ACCURACY_ALPHA;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_ACCURACY_COLOR;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_ACCURACY_RADIUS;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_BACKGROUND_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_BACKGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_BEARING_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_COMPASS_BEARING;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_FOREGROUND_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_FOREGROUND_ICON_OFFSET;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_FOREGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_GPS_BEARING;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_LOCATION_STALE;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_SHADOW_ICON_OFFSET;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.SHADOW_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.SHADOW_LAYER;
import static com.mapbox.mapboxsdk.style.expressions.Expression.interpolate;
import static com.mapbox.mapboxsdk.style.expressions.Expression.linear;
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
import static com.mapbox.mapboxsdk.style.expressions.Expression.zoom;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
import static com.mapbox.mapboxsdk.utils.ColorUtils.colorToRgbaString;
final class LocationLayerController {
private static final String TAG = "Mbgl-LocationLayerController";
@RenderMode.Mode
private int renderMode;
private final MapboxMap mapboxMap;
private Style style;
private final LayerSourceProvider layerSourceProvider;
private final LayerBitmapProvider bitmapProvider;
private LocationComponentOptions options;
private final OnRenderModeChangedListener internalRenderModeChangedListener;
@VisibleForTesting
final Set<String> layerSet = new HashSet<>();
private Feature locationFeature;
private GeoJsonSource locationSource;
private final boolean useSpecializedLocationLayer;
private boolean isHidden = true;
private boolean isStale;
private LocationComponentPositionManager positionManager;
LocationLayerController(MapboxMap mapboxMap, Style style, LayerSourceProvider layerSourceProvider,
LayerFeatureProvider featureProvider, LayerBitmapProvider bitmapProvider,
private LocationLayerRenderer locationLayerRenderer;
LocationLayerController(MapboxMap mapboxMap, Style style,
LayerSourceProvider layerSourceProvider,
LayerFeatureProvider featureProvider,
LayerBitmapProvider bitmapProvider,
@NonNull LocationComponentOptions options,
@NonNull OnRenderModeChangedListener internalRenderModeChangedListener) {
@NonNull OnRenderModeChangedListener internalRenderModeChangedListener,
boolean useSpecializedLocationLayer) {
this.mapboxMap = mapboxMap;
this.style = style;
this.layerSourceProvider = layerSourceProvider;
this.bitmapProvider = bitmapProvider;
this.locationFeature = featureProvider.generateLocationFeature(locationFeature, options);
this.internalRenderModeChangedListener = internalRenderModeChangedListener;
this.useSpecializedLocationLayer = useSpecializedLocationLayer;
this.isStale = options.enableStaleState();
if (useSpecializedLocationLayer) {
locationLayerRenderer = new IndicatorLocationLayerRenderer(style, layerSourceProvider);
} else {
locationLayerRenderer = new SymbolLocationLayerRenderer(style, layerSourceProvider, featureProvider, isStale);
}
initializeComponents(style, options);
}
void initializeComponents(Style style, LocationComponentOptions options) {
this.style = style;
this.positionManager = new LocationComponentPositionManager(style, options.layerAbove(), options.layerBelow());
addLocationSource();
addLayers();
locationLayerRenderer.initializeComponents(style);
locationLayerRenderer.addLayers(positionManager);
applyStyle(options);
if (isHidden) {
@@ -108,24 +89,16 @@ final class LocationLayerController {
void applyStyle(@NonNull LocationComponentOptions options) {
if (positionManager.update(options.layerAbove(), options.layerBelow())) {
removeLayers();
addLayers();
locationLayerRenderer.removeLayers();
locationLayerRenderer.addLayers(positionManager);
if (isHidden) {
hide();
}
}
this.options = options;
float elevation = options.elevation();
// Only add icon elevation if the values greater than 0.
if (elevation > 0) {
styleShadow(options);
}
styleForeground(options);
styleBackground(options);
styleBearing(options);
styleAccuracy(options.accuracyAlpha(), options.accuracyColor());
styleBitmaps(options);
locationLayerRenderer.styleAccuracy(options.accuracyAlpha(), options.accuracyColor());
styleScaling(options);
determineIconsSource(options);
@@ -140,7 +113,7 @@ final class LocationLayerController {
}
this.renderMode = renderMode;
styleForeground(options);
styleBitmaps(options);
determineIconsSource(options);
if (!isHidden) {
show();
@@ -158,59 +131,12 @@ final class LocationLayerController {
void show() {
isHidden = false;
boolean isStale = locationFeature.getBooleanProperty(PROPERTY_LOCATION_STALE);
switch (renderMode) {
case RenderMode.NORMAL:
setLayerVisibility(SHADOW_LAYER, true);
setLayerVisibility(FOREGROUND_LAYER, true);
setLayerVisibility(BACKGROUND_LAYER, true);
setLayerVisibility(ACCURACY_LAYER, !isStale);
setLayerVisibility(BEARING_LAYER, false);
break;
case RenderMode.COMPASS:
setLayerVisibility(SHADOW_LAYER, true);
setLayerVisibility(FOREGROUND_LAYER, true);
setLayerVisibility(BACKGROUND_LAYER, true);
setLayerVisibility(ACCURACY_LAYER, !isStale);
setLayerVisibility(BEARING_LAYER, true);
break;
case RenderMode.GPS:
setLayerVisibility(SHADOW_LAYER, false);
setLayerVisibility(FOREGROUND_LAYER, true);
setLayerVisibility(BACKGROUND_LAYER, true);
setLayerVisibility(ACCURACY_LAYER, false);
setLayerVisibility(BEARING_LAYER, false);
break;
default:
break;
}
locationLayerRenderer.show(renderMode, isStale);
}
void hide() {
isHidden = true;
for (String layerId : layerSet) {
setLayerVisibility(layerId, false);
}
}
void updateForegroundOffset(double tilt) {
JsonArray foregroundJsonArray = new JsonArray();
foregroundJsonArray.add(0f);
foregroundJsonArray.add((float) (-0.05 * tilt));
locationFeature.addProperty(PROPERTY_FOREGROUND_ICON_OFFSET, foregroundJsonArray);
JsonArray backgroundJsonArray = new JsonArray();
backgroundJsonArray.add(0f);
backgroundJsonArray.add((float) (0.05 * tilt));
locationFeature.addProperty(PROPERTY_SHADOW_ICON_OFFSET, backgroundJsonArray);
refreshSource();
}
void updateForegroundBearing(float bearing) {
if (renderMode != RenderMode.GPS) {
setBearingProperty(PROPERTY_GPS_BEARING, bearing);
}
locationLayerRenderer.hide();
}
boolean isHidden() {
@@ -221,148 +147,63 @@ final class LocationLayerController {
return renderMode == RenderMode.COMPASS;
}
private void setLayerVisibility(@NonNull String layerId, boolean visible) {
Layer layer = style.getLayer(layerId);
if (layer != null) {
String targetVisibility = visible ? VISIBLE : NONE;
if (!layer.getVisibility().value.equals(targetVisibility)) {
layer.setProperties(visibility(visible ? VISIBLE : NONE));
}
}
}
private void addLayers() {
// positions the top-most reference layer
Layer layer = layerSourceProvider.generateLayer(BEARING_LAYER);
positionManager.addLayerToMap(layer);
layerSet.add(layer.getId());
// adds remaining layers while keeping the order
addSymbolLayer(FOREGROUND_LAYER, BEARING_LAYER);
addSymbolLayer(BACKGROUND_LAYER, FOREGROUND_LAYER);
addSymbolLayer(SHADOW_LAYER, BACKGROUND_LAYER);
addAccuracyLayer();
}
private void addSymbolLayer(@NonNull String layerId, @NonNull String beforeLayerId) {
Layer layer = layerSourceProvider.generateLayer(layerId);
addLayerToMap(layer, beforeLayerId);
}
private void addAccuracyLayer() {
Layer accuracyLayer = layerSourceProvider.generateAccuracyLayer();
addLayerToMap(accuracyLayer, BACKGROUND_LAYER);
}
private void addLayerToMap(Layer layer, @NonNull String idBelowLayer) {
style.addLayerBelow(layer, idBelowLayer);
layerSet.add(layer.getId());
}
private void removeLayers() {
for (String layerId : layerSet) {
style.removeLayer(layerId);
}
layerSet.clear();
}
private void setBearingProperty(@NonNull String propertyId, float bearing) {
locationFeature.addNumberProperty(propertyId, bearing);
refreshSource();
}
private void updateAccuracyRadius(float accuracy) {
locationFeature.addNumberProperty(PROPERTY_ACCURACY_RADIUS, accuracy);
refreshSource();
}
//
// Source actions
//
private void addLocationSource() {
locationSource = layerSourceProvider.generateSource(locationFeature);
style.addSource(locationSource);
}
private void refreshSource() {
GeoJsonSource source = style.getSourceAs(LOCATION_SOURCE);
if (source != null) {
locationSource.setGeoJson(locationFeature);
}
}
private void setLocationPoint(Point locationPoint) {
JsonObject properties = locationFeature.properties();
if (properties != null) {
locationFeature = Feature.fromGeometry(locationPoint, properties);
refreshSource();
}
}
//
// Styling
//
private void styleBackground(LocationComponentOptions options) {
private void styleBitmaps(LocationComponentOptions options) {
// shadow
Bitmap shadowBitmap = null;
if (options.elevation() > 0) {
// Only add icon elevation if the values greater than 0.
shadowBitmap = bitmapProvider.generateShadowBitmap(options);
}
// background
Bitmap backgroundBitmap = bitmapProvider.generateBitmap(
options.backgroundDrawable(), options.backgroundTintColor()
);
Bitmap backgroundStaleBitmap = bitmapProvider.generateBitmap(
options.backgroundDrawableStale(), options.backgroundStaleTintColor()
);
style.addImage(BACKGROUND_ICON, backgroundBitmap);
style.addImage(BACKGROUND_STALE_ICON, backgroundStaleBitmap);
}
private void styleShadow(@NonNull LocationComponentOptions options) {
style.addImage(SHADOW_ICON, bitmapProvider.generateShadowBitmap(options));
}
private void styleBearing(LocationComponentOptions options) {
// compass bearing
Bitmap bearingBitmap = bitmapProvider.generateBitmap(options.bearingDrawable(), options.bearingTintColor());
style.addImage(BEARING_ICON, bearingBitmap);
}
private void styleAccuracy(float accuracyAlpha, @ColorInt int accuracyColor) {
locationFeature.addNumberProperty(PROPERTY_ACCURACY_ALPHA, accuracyAlpha);
locationFeature.addStringProperty(PROPERTY_ACCURACY_COLOR, colorToRgbaString(accuracyColor));
refreshSource();
}
private void styleForeground(LocationComponentOptions options) {
// foreground
Bitmap foregroundBitmap = bitmapProvider.generateBitmap(
options.foregroundDrawable(), options.foregroundTintColor()
);
Bitmap foregroundBitmapStale = bitmapProvider.generateBitmap(
Bitmap foregroundStaleBitmap = bitmapProvider.generateBitmap(
options.foregroundDrawableStale(), options.foregroundStaleTintColor()
);
if (renderMode == RenderMode.GPS) {
foregroundBitmap = bitmapProvider.generateBitmap(
options.gpsDrawable(), options.foregroundTintColor()
);
foregroundBitmapStale = bitmapProvider.generateBitmap(
foregroundStaleBitmap = bitmapProvider.generateBitmap(
options.gpsDrawable(), options.foregroundStaleTintColor()
);
}
style.addImage(FOREGROUND_ICON, foregroundBitmap);
style.addImage(FOREGROUND_STALE_ICON, foregroundBitmapStale);
locationLayerRenderer.addBitmaps(
renderMode,
shadowBitmap,
backgroundBitmap,
backgroundStaleBitmap,
bearingBitmap,
foregroundBitmap,
foregroundStaleBitmap
);
}
private void styleScaling(@NonNull LocationComponentOptions options) {
for (String layerId : layerSet) {
Layer layer = style.getLayer(layerId);
if (layer instanceof SymbolLayer) {
layer.setProperties(
iconSize(
interpolate(linear(), zoom(),
stop(mapboxMap.getMinZoomLevel(), options.minZoomIconScale()),
stop(mapboxMap.getMaxZoomLevel(), options.maxZoomIconScale())
)
)
);
}
}
Expression scaleExpression = interpolate(linear(), zoom(),
stop(mapboxMap.getMinZoomLevel(), options.minZoomIconScale()),
stop(mapboxMap.getMaxZoomLevel(), options.maxZoomIconScale())
);
locationLayerRenderer.styleScaling(scaleExpression);
}
private void determineIconsSource(LocationComponentOptions options) {
@@ -373,28 +214,30 @@ final class LocationLayerController {
String backgroundStaleIconString = buildIconString(options.backgroundStaleName(), BACKGROUND_STALE_ICON);
String bearingIconString = buildIconString(options.bearingName(), BEARING_ICON);
locationFeature.addStringProperty(PROPERTY_FOREGROUND_ICON, foregroundIconString);
locationFeature.addStringProperty(PROPERTY_BACKGROUND_ICON, backgroundIconString);
locationFeature.addStringProperty(PROPERTY_FOREGROUND_STALE_ICON, foregroundStaleIconString);
locationFeature.addStringProperty(PROPERTY_BACKGROUND_STALE_ICON, backgroundStaleIconString);
locationFeature.addStringProperty(PROPERTY_BEARING_ICON, bearingIconString);
refreshSource();
locationLayerRenderer.updateIconIds(
foregroundIconString,
foregroundStaleIconString,
backgroundIconString,
backgroundStaleIconString,
bearingIconString
);
}
@NonNull
private String buildIconString(@Nullable String bitmapName, @NonNull String drawableName) {
if (bitmapName != null) {
if (useSpecializedLocationLayer) {
Logger.e(TAG, bitmapName + " replacement ID provided for an unsupported specialized location layer");
return drawableName;
}
return bitmapName;
}
return drawableName;
}
void setLocationsStale(boolean isStale) {
locationFeature.addBooleanProperty(PROPERTY_LOCATION_STALE, isStale);
refreshSource();
if (renderMode != RenderMode.GPS) {
setLayerVisibility(ACCURACY_LAYER, !isStale);
}
this.isStale = isStale;
locationLayerRenderer.setLocationStale(isStale, renderMode);
}
//
@@ -415,8 +258,7 @@ final class LocationLayerController {
new MapboxAnimator.AnimationsValueChangeListener<LatLng>() {
@Override
public void onNewAnimationValue(LatLng value) {
Point point = Point.fromLngLat(value.getLongitude(), value.getLatitude());
setLocationPoint(point);
locationLayerRenderer.setLatLng(value);
}
};
@@ -424,7 +266,7 @@ final class LocationLayerController {
new MapboxAnimator.AnimationsValueChangeListener<Float>() {
@Override
public void onNewAnimationValue(Float value) {
setBearingProperty(PROPERTY_GPS_BEARING, value);
locationLayerRenderer.setGpsBearing(value);
}
};
@@ -432,7 +274,7 @@ final class LocationLayerController {
new MapboxAnimator.AnimationsValueChangeListener<Float>() {
@Override
public void onNewAnimationValue(Float value) {
setBearingProperty(PROPERTY_COMPASS_BEARING, value);
locationLayerRenderer.setCompassBearing(value);
}
};
@@ -440,7 +282,7 @@ final class LocationLayerController {
new MapboxAnimator.AnimationsValueChangeListener<Float>() {
@Override
public void onNewAnimationValue(Float value) {
updateAccuracyRadius(value);
locationLayerRenderer.setAccuracyRadius(value);
}
};
@@ -461,4 +303,14 @@ final class LocationLayerController {
return holders;
}
void cameraBearingUpdated(double bearing) {
if (renderMode != RenderMode.GPS) {
locationLayerRenderer.cameraBearingUpdated(bearing);
}
}
void cameraTiltUpdated(double tilt) {
locationLayerRenderer.cameraTiltUpdated(tilt);
}
}

View File

@@ -0,0 +1,47 @@
package com.mapbox.mapboxsdk.location;
import android.graphics.Bitmap;
import androidx.annotation.Nullable;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.location.modes.RenderMode;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.style.expressions.Expression;
interface LocationLayerRenderer {
void initializeComponents(Style style);
void addLayers(LocationComponentPositionManager positionManager);
void removeLayers();
void hide();
void cameraTiltUpdated(double tilt);
void cameraBearingUpdated(double bearing);
void show(@RenderMode.Mode int renderMode, boolean isStale);
void styleAccuracy(float accuracyAlpha, int accuracyColor);
void setLatLng(LatLng latLng);
void setGpsBearing(Float gpsBearing);
void setCompassBearing(Float compassBearing);
void setAccuracyRadius(Float accuracy);
void styleScaling(Expression scaleExpression);
void setLocationStale(boolean isStale, int renderMode);
void updateIconIds(String foregroundIconString, String foregroundStaleIconString, String backgroundIconString,
String backgroundStaleIconString, String bearingIconString);
void addBitmaps(@RenderMode.Mode int renderMode, @Nullable Bitmap shadowBitmap, Bitmap backgroundBitmap,
Bitmap backgroundStaleBitmap, Bitmap bearingBitmap,
Bitmap foregroundBitmap, Bitmap foregroundStaleBitmap);
}

View File

@@ -0,0 +1,293 @@
package com.mapbox.mapboxsdk.location;
import android.graphics.Bitmap;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.location.modes.RenderMode;
import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import java.util.Set;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.ACCURACY_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BACKGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BEARING_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.BEARING_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_LAYER;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.FOREGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.LOCATION_SOURCE;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_ACCURACY_ALPHA;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_ACCURACY_COLOR;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_ACCURACY_RADIUS;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_BACKGROUND_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_BACKGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_BEARING_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_COMPASS_BEARING;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_FOREGROUND_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_FOREGROUND_ICON_OFFSET;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_FOREGROUND_STALE_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_GPS_BEARING;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_LOCATION_STALE;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.PROPERTY_SHADOW_ICON_OFFSET;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.SHADOW_ICON;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.SHADOW_LAYER;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
import static com.mapbox.mapboxsdk.utils.ColorUtils.colorToRgbaString;
final class SymbolLocationLayerRenderer implements LocationLayerRenderer {
private Style style;
private final LayerSourceProvider layerSourceProvider;
private final Set<String> layerSet;
private Feature locationFeature;
private GeoJsonSource locationSource;
SymbolLocationLayerRenderer(Style style,
LayerSourceProvider layerSourceProvider,
LayerFeatureProvider featureProvider,
boolean isStale) {
this.style = style;
this.layerSourceProvider = layerSourceProvider;
this.layerSet = layerSourceProvider.getEmptyLayerSet();
this.locationFeature = featureProvider.generateLocationFeature(locationFeature, isStale);
}
@Override
public void initializeComponents(Style style) {
this.style = style;
addLocationSource();
}
@Override
public void addLayers(LocationComponentPositionManager positionManager) {
// positions the top-most reference layer
Layer layer = layerSourceProvider.generateLayer(BEARING_LAYER);
positionManager.addLayerToMap(layer);
layerSet.add(layer.getId());
// adds remaining layers while keeping the order
addSymbolLayer(FOREGROUND_LAYER, BEARING_LAYER);
addSymbolLayer(BACKGROUND_LAYER, FOREGROUND_LAYER);
addSymbolLayer(SHADOW_LAYER, BACKGROUND_LAYER);
addAccuracyLayer();
}
@Override
public void removeLayers() {
for (String layerId : layerSet) {
style.removeLayer(layerId);
}
layerSet.clear();
}
@Override
public void hide() {
for (String layerId : layerSet) {
setLayerVisibility(layerId, false);
}
}
@Override
public void cameraTiltUpdated(double tilt) {
updateForegroundOffset(tilt);
}
@Override
public void cameraBearingUpdated(double bearing) {
updateForegroundBearing((float) bearing);
}
@Override
public void show(@RenderMode.Mode int renderMode, boolean isStale) {
switch (renderMode) {
case RenderMode.NORMAL:
setLayerVisibility(SHADOW_LAYER, true);
setLayerVisibility(FOREGROUND_LAYER, true);
setLayerVisibility(BACKGROUND_LAYER, true);
setLayerVisibility(ACCURACY_LAYER, !isStale);
setLayerVisibility(BEARING_LAYER, false);
break;
case RenderMode.COMPASS:
setLayerVisibility(SHADOW_LAYER, true);
setLayerVisibility(FOREGROUND_LAYER, true);
setLayerVisibility(BACKGROUND_LAYER, true);
setLayerVisibility(ACCURACY_LAYER, !isStale);
setLayerVisibility(BEARING_LAYER, true);
break;
case RenderMode.GPS:
setLayerVisibility(SHADOW_LAYER, false);
setLayerVisibility(FOREGROUND_LAYER, true);
setLayerVisibility(BACKGROUND_LAYER, true);
setLayerVisibility(ACCURACY_LAYER, false);
setLayerVisibility(BEARING_LAYER, false);
break;
default:
break;
}
}
@Override
public void styleAccuracy(float accuracyAlpha, int accuracyColor) {
locationFeature.addNumberProperty(PROPERTY_ACCURACY_ALPHA, accuracyAlpha);
locationFeature.addStringProperty(PROPERTY_ACCURACY_COLOR, colorToRgbaString(accuracyColor));
refreshSource();
}
@Override
public void setLatLng(LatLng latLng) {
Point point = Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude());
setLocationPoint(point);
}
@Override
public void setGpsBearing(Float gpsBearing) {
setBearingProperty(PROPERTY_GPS_BEARING, gpsBearing);
}
@Override
public void setCompassBearing(Float compassBearing) {
setBearingProperty(PROPERTY_COMPASS_BEARING, compassBearing);
}
@Override
public void setAccuracyRadius(Float accuracy) {
updateAccuracyRadius(accuracy);
}
@Override
public void styleScaling(Expression scaleExpression) {
for (String layerId : layerSet) {
Layer layer = style.getLayer(layerId);
if (layer instanceof SymbolLayer) {
layer.setProperties(
iconSize(scaleExpression)
);
}
}
}
@Override
public void setLocationStale(boolean isStale, int renderMode) {
locationFeature.addBooleanProperty(PROPERTY_LOCATION_STALE, isStale);
refreshSource();
if (renderMode != RenderMode.GPS) {
setLayerVisibility(ACCURACY_LAYER, !isStale);
}
}
@Override
public void updateIconIds(String foregroundIconString, String foregroundStaleIconString, String backgroundIconString,
String backgroundStaleIconString, String bearingIconString) {
locationFeature.addStringProperty(PROPERTY_FOREGROUND_ICON, foregroundIconString);
locationFeature.addStringProperty(PROPERTY_BACKGROUND_ICON, backgroundIconString);
locationFeature.addStringProperty(PROPERTY_FOREGROUND_STALE_ICON, foregroundStaleIconString);
locationFeature.addStringProperty(PROPERTY_BACKGROUND_STALE_ICON, backgroundStaleIconString);
locationFeature.addStringProperty(PROPERTY_BEARING_ICON, bearingIconString);
refreshSource();
}
@Override
public void addBitmaps(@RenderMode.Mode int renderMode, @Nullable Bitmap shadowBitmap, Bitmap backgroundBitmap,
Bitmap backgroundStaleBitmap, Bitmap bearingBitmap,
Bitmap foregroundBitmap, Bitmap foregroundBitmapStale) {
if (shadowBitmap != null) {
style.addImage(SHADOW_ICON, shadowBitmap);
} else {
style.removeImage(SHADOW_ICON);
}
style.addImage(BACKGROUND_ICON, backgroundBitmap);
style.addImage(BACKGROUND_STALE_ICON, backgroundStaleBitmap);
style.addImage(BEARING_ICON, bearingBitmap);
style.addImage(FOREGROUND_ICON, foregroundBitmap);
style.addImage(FOREGROUND_STALE_ICON, foregroundBitmapStale);
}
private void updateForegroundOffset(double tilt) {
JsonArray foregroundJsonArray = new JsonArray();
foregroundJsonArray.add(0f);
foregroundJsonArray.add((float) (-0.05 * tilt));
locationFeature.addProperty(PROPERTY_FOREGROUND_ICON_OFFSET, foregroundJsonArray);
JsonArray backgroundJsonArray = new JsonArray();
backgroundJsonArray.add(0f);
backgroundJsonArray.add((float) (0.05 * tilt));
locationFeature.addProperty(PROPERTY_SHADOW_ICON_OFFSET, backgroundJsonArray);
refreshSource();
}
private void updateForegroundBearing(float bearing) {
setBearingProperty(PROPERTY_GPS_BEARING, bearing);
}
private void setLayerVisibility(@NonNull String layerId, boolean visible) {
Layer layer = style.getLayer(layerId);
if (layer != null) {
String targetVisibility = visible ? VISIBLE : NONE;
if (!layer.getVisibility().value.equals(targetVisibility)) {
layer.setProperties(visibility(visible ? VISIBLE : NONE));
}
}
}
private void addSymbolLayer(@NonNull String layerId, @NonNull String beforeLayerId) {
Layer layer = layerSourceProvider.generateLayer(layerId);
addLayerToMap(layer, beforeLayerId);
}
private void addAccuracyLayer() {
Layer accuracyLayer = layerSourceProvider.generateAccuracyLayer();
addLayerToMap(accuracyLayer, BACKGROUND_LAYER);
}
private void addLayerToMap(Layer layer, @NonNull String idBelowLayer) {
style.addLayerBelow(layer, idBelowLayer);
layerSet.add(layer.getId());
}
private void addLocationSource() {
locationSource = layerSourceProvider.generateSource(locationFeature);
style.addSource(locationSource);
}
private void refreshSource() {
GeoJsonSource source = style.getSourceAs(LOCATION_SOURCE);
if (source != null) {
locationSource.setGeoJson(locationFeature);
}
}
private void setLocationPoint(Point locationPoint) {
JsonObject properties = locationFeature.properties();
if (properties != null) {
locationFeature = Feature.fromGeometry(locationPoint, properties);
refreshSource();
}
}
private void setBearingProperty(@NonNull String propertyId, float bearing) {
locationFeature.addNumberProperty(propertyId, bearing);
refreshSource();
}
private void updateAccuracyRadius(float accuracy) {
locationFeature.addNumberProperty(PROPERTY_ACCURACY_RADIUS, accuracy);
refreshSource();
}
}

View File

@@ -0,0 +1,565 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
package com.mapbox.mapboxsdk.style.layers;
import androidx.annotation.ColorInt;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
/**
*
*
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#layers-location-indicator">The online documentation</a>
*/
@UiThread
public class LocationIndicatorLayer extends Layer {
/**
* Creates a LocationIndicatorLayer.
*
* @param nativePtr pointer used by core
*/
@Keep
LocationIndicatorLayer(long nativePtr) {
super(nativePtr);
}
/**
* Creates a LocationIndicatorLayer.
*
* @param layerId the id of the layer
*/
public LocationIndicatorLayer(String layerId) {
super();
initialize(layerId);
}
@Keep
protected native void initialize(String layerId);
/**
* Get the source id.
*
* @return id of the source
*/
@NonNull
public String getSourceId() {
checkThread();
return nativeGetSourceId();
}
/**
* Get the source layer.
*
* @return sourceLayer the source layer to get
*/
@NonNull
public String getSourceLayer() {
checkThread();
return nativeGetSourceLayer();
}
/**
* Set a single expression filter.
*
* @param filter the expression filter to set
*/
public void setFilter(@NonNull Expression filter) {
checkThread();
nativeSetFilter(filter.toArray());
}
/**
* Set a single expression filter.
*
* @param filter the expression filter to set
* @return This
*/
@NonNull
public LocationIndicatorLayer withFilter(@NonNull Expression filter) {
setFilter(filter);
return this;
}
/**
* Get a single expression filter.
*
* @return the expression filter to get
*/
@Nullable
public Expression getFilter() {
checkThread();
JsonElement jsonElement = nativeGetFilter();
if (jsonElement != null) {
return Expression.Converter.convert(jsonElement);
} else {
return null;
}
}
/**
* Set a property or properties.
*
* @param properties the var-args properties
* @return This
*/
@NonNull
public LocationIndicatorLayer withProperties(@NonNull PropertyValue<?>... properties) {
setProperties(properties);
return this;
}
// Property getters
/**
* Get the TopImage property
*
* @return property wrapper value around String
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<String> getTopImage() {
checkThread();
return (PropertyValue<String>) new PropertyValue("top-image", nativeGetTopImage());
}
/**
* Get the BearingImage property
*
* @return property wrapper value around String
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<String> getBearingImage() {
checkThread();
return (PropertyValue<String>) new PropertyValue("bearing-image", nativeGetBearingImage());
}
/**
* Get the ShadowImage property
*
* @return property wrapper value around String
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<String> getShadowImage() {
checkThread();
return (PropertyValue<String>) new PropertyValue("shadow-image", nativeGetShadowImage());
}
/**
* Get the PerspectiveCompensation property
*
* @return property wrapper value around Float
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<Float> getPerspectiveCompensation() {
checkThread();
return (PropertyValue<Float>) new PropertyValue("perspective-compensation", nativeGetPerspectiveCompensation());
}
/**
* Get the ImageTiltDisplacement property
*
* @return property wrapper value around Float
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<Float> getImageTiltDisplacement() {
checkThread();
return (PropertyValue<Float>) new PropertyValue("image-tilt-displacement", nativeGetImageTiltDisplacement());
}
/**
* Get the Bearing property
*
* @return property wrapper value around Double
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<Double> getBearing() {
checkThread();
return (PropertyValue<Double>) new PropertyValue("bearing", nativeGetBearing());
}
/**
* Get the Location property
*
* @return property wrapper value around Double[]
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<Double[]> getLocation() {
checkThread();
return (PropertyValue<Double[]>) new PropertyValue("location", nativeGetLocation());
}
/**
* Get the Location property transition options
*
* @return transition options for Double[]
*/
@NonNull
public TransitionOptions getLocationTransition() {
checkThread();
return nativeGetLocationTransition();
}
/**
* Set the Location property transition options
*
* @param options transition options for Double[]
*/
public void setLocationTransition(@NonNull TransitionOptions options) {
checkThread();
nativeSetLocationTransition(options.getDuration(), options.getDelay());
}
/**
* Get the AccuracyRadius property
*
* @return property wrapper value around Float
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<Float> getAccuracyRadius() {
checkThread();
return (PropertyValue<Float>) new PropertyValue("accuracy-radius", nativeGetAccuracyRadius());
}
/**
* Get the AccuracyRadius property transition options
*
* @return transition options for Float
*/
@NonNull
public TransitionOptions getAccuracyRadiusTransition() {
checkThread();
return nativeGetAccuracyRadiusTransition();
}
/**
* Set the AccuracyRadius property transition options
*
* @param options transition options for Float
*/
public void setAccuracyRadiusTransition(@NonNull TransitionOptions options) {
checkThread();
nativeSetAccuracyRadiusTransition(options.getDuration(), options.getDelay());
}
/**
* Get the TopImageSize property
*
* @return property wrapper value around Float
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<Float> getTopImageSize() {
checkThread();
return (PropertyValue<Float>) new PropertyValue("top-image-size", nativeGetTopImageSize());
}
/**
* Get the TopImageSize property transition options
*
* @return transition options for Float
*/
@NonNull
public TransitionOptions getTopImageSizeTransition() {
checkThread();
return nativeGetTopImageSizeTransition();
}
/**
* Set the TopImageSize property transition options
*
* @param options transition options for Float
*/
public void setTopImageSizeTransition(@NonNull TransitionOptions options) {
checkThread();
nativeSetTopImageSizeTransition(options.getDuration(), options.getDelay());
}
/**
* Get the BearingImageSize property
*
* @return property wrapper value around Float
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<Float> getBearingImageSize() {
checkThread();
return (PropertyValue<Float>) new PropertyValue("bearing-image-size", nativeGetBearingImageSize());
}
/**
* Get the BearingImageSize property transition options
*
* @return transition options for Float
*/
@NonNull
public TransitionOptions getBearingImageSizeTransition() {
checkThread();
return nativeGetBearingImageSizeTransition();
}
/**
* Set the BearingImageSize property transition options
*
* @param options transition options for Float
*/
public void setBearingImageSizeTransition(@NonNull TransitionOptions options) {
checkThread();
nativeSetBearingImageSizeTransition(options.getDuration(), options.getDelay());
}
/**
* Get the ShadowImageSize property
*
* @return property wrapper value around Float
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<Float> getShadowImageSize() {
checkThread();
return (PropertyValue<Float>) new PropertyValue("shadow-image-size", nativeGetShadowImageSize());
}
/**
* Get the ShadowImageSize property transition options
*
* @return transition options for Float
*/
@NonNull
public TransitionOptions getShadowImageSizeTransition() {
checkThread();
return nativeGetShadowImageSizeTransition();
}
/**
* Set the ShadowImageSize property transition options
*
* @param options transition options for Float
*/
public void setShadowImageSizeTransition(@NonNull TransitionOptions options) {
checkThread();
nativeSetShadowImageSizeTransition(options.getDuration(), options.getDelay());
}
/**
* Get the AccuracyRadiusColor property
*
* @return property wrapper value around String
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<String> getAccuracyRadiusColor() {
checkThread();
return (PropertyValue<String>) new PropertyValue("accuracy-radius-color", nativeGetAccuracyRadiusColor());
}
/**
* The color for drawing the accuracy radius, as a circle. To adjust transparency, set the alpha component of the color accordingly.
*
* @return int representation of a rgba string color
* @throws RuntimeException thrown if property isn't a value
*/
@ColorInt
public int getAccuracyRadiusColorAsInt() {
checkThread();
PropertyValue<String> value = getAccuracyRadiusColor();
if (value.isValue()) {
return rgbaToColor(value.getValue());
} else {
throw new RuntimeException("accuracy-radius-color was set as a Function");
}
}
/**
* Get the AccuracyRadiusColor property transition options
*
* @return transition options for String
*/
@NonNull
public TransitionOptions getAccuracyRadiusColorTransition() {
checkThread();
return nativeGetAccuracyRadiusColorTransition();
}
/**
* Set the AccuracyRadiusColor property transition options
*
* @param options transition options for String
*/
public void setAccuracyRadiusColorTransition(@NonNull TransitionOptions options) {
checkThread();
nativeSetAccuracyRadiusColorTransition(options.getDuration(), options.getDelay());
}
/**
* Get the AccuracyRadiusBorderColor property
*
* @return property wrapper value around String
*/
@NonNull
@SuppressWarnings("unchecked")
public PropertyValue<String> getAccuracyRadiusBorderColor() {
checkThread();
return (PropertyValue<String>) new PropertyValue("accuracy-radius-border-color", nativeGetAccuracyRadiusBorderColor());
}
/**
* The color for drawing the accuracy radius border. To adjust transparency, set the alpha component of the color accordingly.
*
* @return int representation of a rgba string color
* @throws RuntimeException thrown if property isn't a value
*/
@ColorInt
public int getAccuracyRadiusBorderColorAsInt() {
checkThread();
PropertyValue<String> value = getAccuracyRadiusBorderColor();
if (value.isValue()) {
return rgbaToColor(value.getValue());
} else {
throw new RuntimeException("accuracy-radius-border-color was set as a Function");
}
}
/**
* Get the AccuracyRadiusBorderColor property transition options
*
* @return transition options for String
*/
@NonNull
public TransitionOptions getAccuracyRadiusBorderColorTransition() {
checkThread();
return nativeGetAccuracyRadiusBorderColorTransition();
}
/**
* Set the AccuracyRadiusBorderColor property transition options
*
* @param options transition options for String
*/
public void setAccuracyRadiusBorderColorTransition(@NonNull TransitionOptions options) {
checkThread();
nativeSetAccuracyRadiusBorderColorTransition(options.getDuration(), options.getDelay());
}
@NonNull
@Keep
private native Object nativeGetTopImage();
@NonNull
@Keep
private native Object nativeGetBearingImage();
@NonNull
@Keep
private native Object nativeGetShadowImage();
@NonNull
@Keep
private native Object nativeGetPerspectiveCompensation();
@NonNull
@Keep
private native Object nativeGetImageTiltDisplacement();
@NonNull
@Keep
private native Object nativeGetBearing();
@NonNull
@Keep
private native Object nativeGetLocation();
@NonNull
@Keep
private native TransitionOptions nativeGetLocationTransition();
@Keep
private native void nativeSetLocationTransition(long duration, long delay);
@NonNull
@Keep
private native Object nativeGetAccuracyRadius();
@NonNull
@Keep
private native TransitionOptions nativeGetAccuracyRadiusTransition();
@Keep
private native void nativeSetAccuracyRadiusTransition(long duration, long delay);
@NonNull
@Keep
private native Object nativeGetTopImageSize();
@NonNull
@Keep
private native TransitionOptions nativeGetTopImageSizeTransition();
@Keep
private native void nativeSetTopImageSizeTransition(long duration, long delay);
@NonNull
@Keep
private native Object nativeGetBearingImageSize();
@NonNull
@Keep
private native TransitionOptions nativeGetBearingImageSizeTransition();
@Keep
private native void nativeSetBearingImageSizeTransition(long duration, long delay);
@NonNull
@Keep
private native Object nativeGetShadowImageSize();
@NonNull
@Keep
private native TransitionOptions nativeGetShadowImageSizeTransition();
@Keep
private native void nativeSetShadowImageSizeTransition(long duration, long delay);
@NonNull
@Keep
private native Object nativeGetAccuracyRadiusColor();
@NonNull
@Keep
private native TransitionOptions nativeGetAccuracyRadiusColorTransition();
@Keep
private native void nativeSetAccuracyRadiusColorTransition(long duration, long delay);
@NonNull
@Keep
private native Object nativeGetAccuracyRadiusBorderColor();
@NonNull
@Keep
private native TransitionOptions nativeGetAccuracyRadiusBorderColorTransition();
@Keep
private native void nativeSetAccuracyRadiusBorderColorTransition(long duration, long delay);
@Override
@Keep
protected native void finalize() throws Throwable;
}

View File

@@ -1645,6 +1645,226 @@ public class PropertyFactory {
return new PaintPropertyValue<>("background-opacity", expression);
}
/**
* The amount of the perspective compensation, between 0 and 1. A value of 1 produces a location indicator of constant width across the screen. A value of 0 makes it scale naturally according to the viewing projection.
*
* @param value a Float value
* @return property wrapper around Float
*/
public static PropertyValue<Float> perspectiveCompensation(Float value) {
return new PaintPropertyValue<>("perspective-compensation", value);
}
/**
* The amount of the perspective compensation, between 0 and 1. A value of 1 produces a location indicator of constant width across the screen. A value of 0 makes it scale naturally according to the viewing projection.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> perspectiveCompensation(Expression expression) {
return new PaintPropertyValue<>("perspective-compensation", expression);
}
/**
* The displacement off the center of the top image and the shadow image when the pitch of the map is greater than 0. This helps producing a three-dimensional appearence.
*
* @param value a Float value
* @return property wrapper around Float
*/
public static PropertyValue<Float> imageTiltDisplacement(Float value) {
return new PaintPropertyValue<>("image-tilt-displacement", value);
}
/**
* The displacement off the center of the top image and the shadow image when the pitch of the map is greater than 0. This helps producing a three-dimensional appearence.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> imageTiltDisplacement(Expression expression) {
return new PaintPropertyValue<>("image-tilt-displacement", expression);
}
/**
* The bearing of the location indicator.
*
* @param value a Double value
* @return property wrapper around Double
*/
public static PropertyValue<Double> bearing(Double value) {
return new PaintPropertyValue<>("bearing", value);
}
/**
* The bearing of the location indicator.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> bearing(Expression expression) {
return new PaintPropertyValue<>("bearing", expression);
}
/**
* An array of [latitude, longitude, altitude] position of the location indicator.
*
* @param value a Double[] value
* @return property wrapper around Double[]
*/
public static PropertyValue<Double[]> location(Double[] value) {
return new PaintPropertyValue<>("location", value);
}
/**
* An array of [latitude, longitude, altitude] position of the location indicator.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> location(Expression expression) {
return new PaintPropertyValue<>("location", expression);
}
/**
* The accuracy, in meters, of the position source used to retrieve the position of the location indicator.
*
* @param value a Float value
* @return property wrapper around Float
*/
public static PropertyValue<Float> accuracyRadius(Float value) {
return new PaintPropertyValue<>("accuracy-radius", value);
}
/**
* The accuracy, in meters, of the position source used to retrieve the position of the location indicator.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> accuracyRadius(Expression expression) {
return new PaintPropertyValue<>("accuracy-radius", expression);
}
/**
* The size of the top image, as a scale factor applied to the size of the specified image.
*
* @param value a Float value
* @return property wrapper around Float
*/
public static PropertyValue<Float> topImageSize(Float value) {
return new PaintPropertyValue<>("top-image-size", value);
}
/**
* The size of the top image, as a scale factor applied to the size of the specified image.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> topImageSize(Expression expression) {
return new PaintPropertyValue<>("top-image-size", expression);
}
/**
* The size of the bearing image, as a scale factor applied to the size of the specified image.
*
* @param value a Float value
* @return property wrapper around Float
*/
public static PropertyValue<Float> bearingImageSize(Float value) {
return new PaintPropertyValue<>("bearing-image-size", value);
}
/**
* The size of the bearing image, as a scale factor applied to the size of the specified image.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> bearingImageSize(Expression expression) {
return new PaintPropertyValue<>("bearing-image-size", expression);
}
/**
* The size of the shadow image, as a scale factor applied to the size of the specified image.
*
* @param value a Float value
* @return property wrapper around Float
*/
public static PropertyValue<Float> shadowImageSize(Float value) {
return new PaintPropertyValue<>("shadow-image-size", value);
}
/**
* The size of the shadow image, as a scale factor applied to the size of the specified image.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> shadowImageSize(Expression expression) {
return new PaintPropertyValue<>("shadow-image-size", expression);
}
/**
* The color for drawing the accuracy radius, as a circle. To adjust transparency, set the alpha component of the color accordingly.
*
* @param value a int color value
* @return property wrapper around String color
*/
public static PropertyValue<String> accuracyRadiusColor(@ColorInt int value) {
return new PaintPropertyValue<>("accuracy-radius-color", colorToRgbaString(value));
}
/**
* The color for drawing the accuracy radius, as a circle. To adjust transparency, set the alpha component of the color accordingly.
*
* @param value a String value
* @return property wrapper around String
*/
public static PropertyValue<String> accuracyRadiusColor(String value) {
return new PaintPropertyValue<>("accuracy-radius-color", value);
}
/**
* The color for drawing the accuracy radius, as a circle. To adjust transparency, set the alpha component of the color accordingly.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> accuracyRadiusColor(Expression expression) {
return new PaintPropertyValue<>("accuracy-radius-color", expression);
}
/**
* The color for drawing the accuracy radius border. To adjust transparency, set the alpha component of the color accordingly.
*
* @param value a int color value
* @return property wrapper around String color
*/
public static PropertyValue<String> accuracyRadiusBorderColor(@ColorInt int value) {
return new PaintPropertyValue<>("accuracy-radius-border-color", colorToRgbaString(value));
}
/**
* The color for drawing the accuracy radius border. To adjust transparency, set the alpha component of the color accordingly.
*
* @param value a String value
* @return property wrapper around String
*/
public static PropertyValue<String> accuracyRadiusBorderColor(String value) {
return new PaintPropertyValue<>("accuracy-radius-border-color", value);
}
/**
* The color for drawing the accuracy radius border. To adjust transparency, set the alpha component of the color accordingly.
*
* @param expression an expression statement
* @return property wrapper around an expression statement
*/
public static PropertyValue<Expression> accuracyRadiusBorderColor(Expression expression) {
return new PaintPropertyValue<>("accuracy-radius-border-color", expression);
}
/**
* Sorts features in ascending order based on this value. Features with a higher sort key will appear above features with a lower sort key.
*
@@ -2615,4 +2835,64 @@ public class PropertyFactory {
return new LayoutPropertyValue<>("circle-sort-key", value);
}
/**
* Name of image in sprite to use as the top of the location indicator.
*
* @param value a String value
* @return property wrapper around String
*/
public static PropertyValue<String> topImage(String value) {
return new LayoutPropertyValue<>("top-image", value);
}
/**
* Name of image in sprite to use as the top of the location indicator.
*
* @param value a String value
* @return property wrapper around String
*/
public static PropertyValue<Expression> topImage(Expression value) {
return new LayoutPropertyValue<>("top-image", value);
}
/**
* Name of image in sprite to use as the middle of the location indicator.
*
* @param value a String value
* @return property wrapper around String
*/
public static PropertyValue<String> bearingImage(String value) {
return new LayoutPropertyValue<>("bearing-image", value);
}
/**
* Name of image in sprite to use as the middle of the location indicator.
*
* @param value a String value
* @return property wrapper around String
*/
public static PropertyValue<Expression> bearingImage(Expression value) {
return new LayoutPropertyValue<>("bearing-image", value);
}
/**
* Name of image in sprite to use as the background of the location indicator.
*
* @param value a String value
* @return property wrapper around String
*/
public static PropertyValue<String> shadowImage(String value) {
return new LayoutPropertyValue<>("shadow-image", value);
}
/**
* Name of image in sprite to use as the background of the location indicator.
*
* @param value a String value
* @return property wrapper around String
*/
public static PropertyValue<Expression> shadowImage(Expression value) {
return new LayoutPropertyValue<>("shadow-image", value);
}
}

View File

@@ -42,7 +42,7 @@ public class <%- camelize(type) %>Layer extends Layer {
super(nativePtr);
}
<% if (type === 'background') { -%>
<% if (type === 'background' || type === 'location-indicator') { -%>
/**
* Creates a <%- camelize(type) %>Layer.
*

View File

@@ -53,10 +53,23 @@ public class BitmapUtils {
* @return the merged bitmap
*/
public static Bitmap mergeBitmap(@NonNull Bitmap background, @NonNull Bitmap foreground) {
return mergeBitmap(background, foreground, 10f, 10f);
}
/**
* Create a bitmap from a background and a foreground bitmap
*
* @param background The bitmap placed in the background
* @param foreground The bitmap placed in the foreground
* @param left position of the left side of the foreground bitmap
* @param top position of the top side of the foreground bitmap
* @return the merged bitmap
*/
public static Bitmap mergeBitmap(@NonNull Bitmap background, @NonNull Bitmap foreground, float left, float top) {
Bitmap result = Bitmap.createBitmap(background.getWidth(), background.getHeight(), background.getConfig());
Canvas canvas = new Canvas(result);
canvas.drawBitmap(background, 0f, 0f, null);
canvas.drawBitmap(foreground, 10, 10, null);
canvas.drawBitmap(foreground, left, top, null);
return result;
}

View File

@@ -16,6 +16,7 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import java.util.HashSet;
import java.util.Set;
import static com.mapbox.mapboxsdk.location.LocationComponentConstants.ACCURACY_LAYER;
@@ -68,7 +69,7 @@ public class LocationLayerControllerTest {
LocationComponentOptions options = mock(LocationComponentOptions.class);
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
verify(style).addSource(locationSource);
}
@@ -85,7 +86,7 @@ public class LocationLayerControllerTest {
LocationComponentOptions options = mock(LocationComponentOptions.class);
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
verify(style).addLayerBelow(shadowLayer, BACKGROUND_LAYER);
}
@@ -102,7 +103,7 @@ public class LocationLayerControllerTest {
LocationComponentOptions options = mock(LocationComponentOptions.class);
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
verify(style).addLayerBelow(backgroundLayer, FOREGROUND_LAYER);
}
@@ -119,7 +120,7 @@ public class LocationLayerControllerTest {
LocationComponentOptions options = mock(LocationComponentOptions.class);
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
verify(style).addLayerBelow(foregroundLayer, BEARING_LAYER);
}
@@ -138,7 +139,7 @@ public class LocationLayerControllerTest {
when(options.layerBelow()).thenReturn(layerBelow);
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
verify(style).addLayerBelow(bearingLayer, layerBelow);
}
@@ -155,7 +156,7 @@ public class LocationLayerControllerTest {
LocationComponentOptions options = mock(LocationComponentOptions.class);
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
verify(style).addLayerBelow(accuracyLayer, BACKGROUND_LAYER);
}
@@ -166,16 +167,18 @@ public class LocationLayerControllerTest {
LayerSourceProvider sourceProvider = buildLayerProvider();
GeoJsonSource locationSource = mock(GeoJsonSource.class);
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
Set<String> layerSet = new HashSet<>();
when(sourceProvider.getEmptyLayerSet()).thenReturn(layerSet);
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
LocationComponentOptions options = mock(LocationComponentOptions.class);
LocationLayerController controller =
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
controller.initializeComponents(mapboxMap.getStyle(), options);
assertEquals(5, controller.layerSet.size());
assertEquals(5, layerSet.size());
}
@Test
@@ -191,7 +194,7 @@ public class LocationLayerControllerTest {
// Style is applied on initialization
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
verify(style).addImage(SHADOW_ICON, bitmap);
}
@@ -208,7 +211,7 @@ public class LocationLayerControllerTest {
when(options.elevation()).thenReturn(0f);
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
verify(style, times(0)).addImage(SHADOW_ICON, bitmap);
}
@@ -228,7 +231,7 @@ public class LocationLayerControllerTest {
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
verify(style).addImage(FOREGROUND_ICON, bitmap);
}
@@ -248,7 +251,7 @@ public class LocationLayerControllerTest {
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
verify(style).addImage(FOREGROUND_STALE_ICON, bitmap);
}
@@ -268,7 +271,7 @@ public class LocationLayerControllerTest {
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
verify(style).addImage(BACKGROUND_ICON, bitmap);
}
@@ -288,7 +291,7 @@ public class LocationLayerControllerTest {
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
verify(style).addImage(BACKGROUND_STALE_ICON, bitmap);
}
@@ -308,7 +311,7 @@ public class LocationLayerControllerTest {
when(bitmapProvider.generateBitmap(drawableResId, tintColor)).thenReturn(bitmap);
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
verify(style).addImage(BEARING_ICON, bitmap);
}
@@ -326,7 +329,7 @@ public class LocationLayerControllerTest {
LocationLayerController layerController =
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
Layer bearingLayer2 = mock(Layer.class);
when(sourceProvider.generateLayer(BEARING_LAYER)).thenReturn(bearingLayer2);
@@ -371,7 +374,7 @@ public class LocationLayerControllerTest {
LocationLayerController layerController =
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
options = mock(LocationComponentOptions.class);
layerBelow = "layer-below";
@@ -394,7 +397,7 @@ public class LocationLayerControllerTest {
LocationLayerController layerController =
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
options = mock(LocationComponentOptions.class);
layerController.applyStyle(options);
@@ -415,10 +418,9 @@ public class LocationLayerControllerTest {
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
bitmapProvider, options, internalRenderModeChangedListener
);
bitmapProvider, options, internalRenderModeChangedListener, false);
layer.updateForegroundOffset(2d);
layer.cameraTiltUpdated(2d);
verify(locationFeature).addProperty(eq(PROPERTY_FOREGROUND_ICON_OFFSET), any(JsonElement.class));
}
@@ -434,9 +436,8 @@ public class LocationLayerControllerTest {
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
bitmapProvider, options, internalRenderModeChangedListener
);
layer.updateForegroundOffset(2d);
bitmapProvider, options, internalRenderModeChangedListener, false);
layer.cameraTiltUpdated(2d);
verify(locationFeature).addProperty(eq(PROPERTY_SHADOW_ICON_OFFSET), any(JsonElement.class));
}
@@ -453,8 +454,7 @@ public class LocationLayerControllerTest {
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
bitmapProvider, options, internalRenderModeChangedListener
);
bitmapProvider, options, internalRenderModeChangedListener, false);
getAnimationListener(ANIMATOR_LAYER_LATLNG, layer.getAnimationListeners()).onNewAnimationValue(new LatLng());
@@ -474,8 +474,7 @@ public class LocationLayerControllerTest {
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
bitmapProvider, options, internalRenderModeChangedListener
);
bitmapProvider, options, internalRenderModeChangedListener, false);
layer.setRenderMode(RenderMode.GPS);
float gpsBearing = 2f;
@@ -496,8 +495,7 @@ public class LocationLayerControllerTest {
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
bitmapProvider, options, internalRenderModeChangedListener
);
bitmapProvider, options, internalRenderModeChangedListener, false);
layer.setRenderMode(RenderMode.COMPASS);
float gpsBearing = 2f;
@@ -517,8 +515,7 @@ public class LocationLayerControllerTest {
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
bitmapProvider, options, internalRenderModeChangedListener
);
bitmapProvider, options, internalRenderModeChangedListener, false);
layer.setRenderMode(RenderMode.COMPASS);
float compassBearing = 2f;
@@ -540,8 +537,7 @@ public class LocationLayerControllerTest {
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
bitmapProvider, options, internalRenderModeChangedListener
);
bitmapProvider, options, internalRenderModeChangedListener, false);
layer.setRenderMode(RenderMode.GPS);
float compassBearing = 2f;
@@ -561,8 +557,7 @@ public class LocationLayerControllerTest {
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
bitmapProvider, options, internalRenderModeChangedListener
);
bitmapProvider, options, internalRenderModeChangedListener, false);
layer.setRenderMode(RenderMode.NORMAL);
float accuracyRadiusValue = 2f;
@@ -584,8 +579,7 @@ public class LocationLayerControllerTest {
Feature locationFeature = mock(Feature.class);
LocationLayerController layer = new LocationLayerController(
mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(locationFeature, options),
bitmapProvider, options, internalRenderModeChangedListener
);
bitmapProvider, options, internalRenderModeChangedListener, false);
layer.setRenderMode(RenderMode.GPS);
float accuracyRadiusValue = 2f;
@@ -605,7 +599,7 @@ public class LocationLayerControllerTest {
LocationLayerController controller =
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
controller.setRenderMode(RenderMode.NORMAL);
controller.setRenderMode(RenderMode.NORMAL);
@@ -624,7 +618,7 @@ public class LocationLayerControllerTest {
LocationLayerController controller =
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
controller.setRenderMode(RenderMode.GPS);
controller.setRenderMode(RenderMode.GPS);
@@ -648,7 +642,7 @@ public class LocationLayerControllerTest {
LocationLayerController controller =
new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options),
bitmapProvider, options, internalRenderModeChangedListener);
bitmapProvider, options, internalRenderModeChangedListener, false);
verify(style).addImage(FOREGROUND_ICON, bitmap);
@@ -669,13 +663,13 @@ public class LocationLayerControllerTest {
private LayerFeatureProvider buildFeatureProvider(@NonNull LocationComponentOptions options) {
LayerFeatureProvider provider = mock(LayerFeatureProvider.class);
when(provider.generateLocationFeature(null, options)).thenReturn(mock(Feature.class));
when(provider.generateLocationFeature(null, options.enableStaleState())).thenReturn(mock(Feature.class));
return provider;
}
private LayerFeatureProvider buildFeatureProvider(Feature feature, @NonNull LocationComponentOptions options) {
LayerFeatureProvider provider = mock(LayerFeatureProvider.class);
when(provider.generateLocationFeature(null, options)).thenReturn(feature);
when(provider.generateLocationFeature(null, options.enableStaleState())).thenReturn(feature);
return provider;
}

View File

@@ -0,0 +1,330 @@
// This file is generated. Edit android/platform/scripts/generate-style-code.js, then run `make android-style-code`.
package com.mapbox.mapboxsdk.testapp.style;
import android.graphics.Color;
import androidx.test.annotation.UiThreadTest;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.mapbox.mapboxsdk.maps.BaseLayerTest;
import org.junit.Before;
import timber.log.Timber;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.LocationIndicatorLayer;
import org.junit.Test;
import org.junit.runner.RunWith;
import static com.mapbox.mapboxsdk.style.expressions.Expression.*;
import static org.junit.Assert.*;
import static com.mapbox.mapboxsdk.style.layers.Property.*;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.*;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
/**
* Basic smoke tests for LocationIndicatorLayer
*/
@RunWith(AndroidJUnit4.class)
public class LocationIndicatorLayerTest extends BaseLayerTest {
private LocationIndicatorLayer layer;
@Before
@UiThreadTest
public void beforeTest(){
super.before();
layer = new LocationIndicatorLayer("my-layer");
setupLayer(layer);
}
@Test
@UiThreadTest
public void testSetVisibility() {
Timber.i("Visibility");
assertNotNull(layer);
// Get initial
assertEquals(layer.getVisibility().getValue(), VISIBLE);
// Set
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
@Test
@UiThreadTest
public void testTopImageAsConstant() {
Timber.i("top-image");
assertNotNull(layer);
assertNull(layer.getTopImage().getValue());
// Set and Get
String propertyValue = "undefined";
layer.setProperties(topImage(propertyValue));
assertEquals(layer.getTopImage().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testBearingImageAsConstant() {
Timber.i("bearing-image");
assertNotNull(layer);
assertNull(layer.getBearingImage().getValue());
// Set and Get
String propertyValue = "undefined";
layer.setProperties(bearingImage(propertyValue));
assertEquals(layer.getBearingImage().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testShadowImageAsConstant() {
Timber.i("shadow-image");
assertNotNull(layer);
assertNull(layer.getShadowImage().getValue());
// Set and Get
String propertyValue = "undefined";
layer.setProperties(shadowImage(propertyValue));
assertEquals(layer.getShadowImage().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testPerspectiveCompensationAsConstant() {
Timber.i("perspective-compensation");
assertNotNull(layer);
assertNull(layer.getPerspectiveCompensation().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(perspectiveCompensation(propertyValue));
assertEquals(layer.getPerspectiveCompensation().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testImageTiltDisplacementAsConstant() {
Timber.i("image-tilt-displacement");
assertNotNull(layer);
assertNull(layer.getImageTiltDisplacement().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(imageTiltDisplacement(propertyValue));
assertEquals(layer.getImageTiltDisplacement().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testBearingAsConstant() {
Timber.i("bearing");
assertNotNull(layer);
assertNull(layer.getBearing().getValue());
// Set and Get
Double propertyValue = 0.3;
layer.setProperties(bearing(propertyValue));
assertEquals(layer.getBearing().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testLocationTransition() {
Timber.i("locationTransitionOptions");
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setLocationTransition(options);
assertEquals(layer.getLocationTransition(), options);
}
@Test
@UiThreadTest
public void testLocationAsConstant() {
Timber.i("location");
assertNotNull(layer);
assertNull(layer.getLocation().getValue());
// Set and Get
Double[] propertyValue = new Double[] {0.0, 0.0, 0.0};
layer.setProperties(location(propertyValue));
assertEquals(layer.getLocation().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testAccuracyRadiusTransition() {
Timber.i("accuracy-radiusTransitionOptions");
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setAccuracyRadiusTransition(options);
assertEquals(layer.getAccuracyRadiusTransition(), options);
}
@Test
@UiThreadTest
public void testAccuracyRadiusAsConstant() {
Timber.i("accuracy-radius");
assertNotNull(layer);
assertNull(layer.getAccuracyRadius().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(accuracyRadius(propertyValue));
assertEquals(layer.getAccuracyRadius().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testTopImageSizeTransition() {
Timber.i("top-image-sizeTransitionOptions");
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setTopImageSizeTransition(options);
assertEquals(layer.getTopImageSizeTransition(), options);
}
@Test
@UiThreadTest
public void testTopImageSizeAsConstant() {
Timber.i("top-image-size");
assertNotNull(layer);
assertNull(layer.getTopImageSize().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(topImageSize(propertyValue));
assertEquals(layer.getTopImageSize().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testBearingImageSizeTransition() {
Timber.i("bearing-image-sizeTransitionOptions");
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setBearingImageSizeTransition(options);
assertEquals(layer.getBearingImageSizeTransition(), options);
}
@Test
@UiThreadTest
public void testBearingImageSizeAsConstant() {
Timber.i("bearing-image-size");
assertNotNull(layer);
assertNull(layer.getBearingImageSize().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(bearingImageSize(propertyValue));
assertEquals(layer.getBearingImageSize().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testShadowImageSizeTransition() {
Timber.i("shadow-image-sizeTransitionOptions");
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setShadowImageSizeTransition(options);
assertEquals(layer.getShadowImageSizeTransition(), options);
}
@Test
@UiThreadTest
public void testShadowImageSizeAsConstant() {
Timber.i("shadow-image-size");
assertNotNull(layer);
assertNull(layer.getShadowImageSize().getValue());
// Set and Get
Float propertyValue = 0.3f;
layer.setProperties(shadowImageSize(propertyValue));
assertEquals(layer.getShadowImageSize().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testAccuracyRadiusColorTransition() {
Timber.i("accuracy-radius-colorTransitionOptions");
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setAccuracyRadiusColorTransition(options);
assertEquals(layer.getAccuracyRadiusColorTransition(), options);
}
@Test
@UiThreadTest
public void testAccuracyRadiusColorAsConstant() {
Timber.i("accuracy-radius-color");
assertNotNull(layer);
assertNull(layer.getAccuracyRadiusColor().getValue());
// Set and Get
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(accuracyRadiusColor(propertyValue));
assertEquals(layer.getAccuracyRadiusColor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testAccuracyRadiusColorAsIntConstant() {
Timber.i("accuracy-radius-color");
assertNotNull(layer);
// Set and Get
layer.setProperties(accuracyRadiusColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getAccuracyRadiusColorAsInt(), Color.argb(127, 255, 127, 0));
}
@Test
@UiThreadTest
public void testAccuracyRadiusBorderColorTransition() {
Timber.i("accuracy-radius-border-colorTransitionOptions");
assertNotNull(layer);
// Set and Get
TransitionOptions options = new TransitionOptions(300, 100);
layer.setAccuracyRadiusBorderColorTransition(options);
assertEquals(layer.getAccuracyRadiusBorderColorTransition(), options);
}
@Test
@UiThreadTest
public void testAccuracyRadiusBorderColorAsConstant() {
Timber.i("accuracy-radius-border-color");
assertNotNull(layer);
assertNull(layer.getAccuracyRadiusBorderColor().getValue());
// Set and Get
String propertyValue = "rgba(255,128,0,0.7)";
layer.setProperties(accuracyRadiusBorderColor(propertyValue));
assertEquals(layer.getAccuracyRadiusBorderColor().getValue(), propertyValue);
}
@Test
@UiThreadTest
public void testAccuracyRadiusBorderColorAsIntConstant() {
Timber.i("accuracy-radius-border-color");
assertNotNull(layer);
// Set and Get
layer.setProperties(accuracyRadiusBorderColor(Color.argb(127, 255, 127, 0)));
assertEquals(layer.getAccuracyRadiusBorderColorAsInt(), Color.argb(127, 255, 127, 0));
}
}

View File

@@ -43,7 +43,7 @@ public class <%- camelize(type) %>LayerTest extends BaseLayerTest {
@UiThreadTest
public void beforeTest(){
super.before();
<% if (type === 'background') { -%>
<% if (type === 'background' || type === 'location-indicator') { -%>
layer = new <%- camelize(type) %>Layer("my-layer");
<% } else { -%>
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
@@ -51,7 +51,7 @@ public class <%- camelize(type) %>LayerTest extends BaseLayerTest {
<% } -%>
setupLayer(layer);
}
<% if (type !== 'background') { -%>
<% if (type !== 'background' && type !== 'location-indicator') { -%>
@Test
@UiThreadTest
@@ -75,7 +75,7 @@ public class <%- camelize(type) %>LayerTest extends BaseLayerTest {
layer.setProperties(visibility(NONE));
assertEquals(layer.getVisibility().getValue(), NONE);
}
<% if (!(type === 'background' || type === 'raster' || type === 'hillshade')) { -%>
<% if (!(type === 'background' || type === 'location-indicator' || type === 'raster' || type === 'hillshade')) { -%>
@Test
@UiThreadTest

View File

@@ -129,6 +129,7 @@ public class LocationModesActivity extends AppCompatActivity implements OnMapRea
locationComponent.activateLocationComponent(
LocationComponentActivationOptions
.builder(this, style)
.useSpecializedLocationLayer(true)
.useDefaultLocationEngine(true)
.locationEngineRequest(new LocationEngineRequest.Builder(750)
.setFastestInterval(750)

View File

@@ -1,195 +0,0 @@
{
"//": "This file can be edited manually and is the canonical source.",
"sources": [
"vendor-android/mapbox-gl-native/platform/android/src/main.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/android_renderer_backend.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/android_renderer_frontend.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/annotation/marker.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/annotation/polygon.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/annotation/polyline.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/async_task.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/attach_env.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/bitmap.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/bitmap_factory.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/conversion/collection.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/conversion/color.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/conversion/constant.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/geojson/feature.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/geojson/feature_collection.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/geojson/geometry.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/geojson/geometry_collection.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/geojson/line_string.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/geojson/multi_line_string.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/geojson/multi_point.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/geojson/multi_polygon.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/geojson/point.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/geojson/polygon.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/geometry/lat_lng.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/geometry/lat_lng_bounds.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/geometry/lat_lng_quad.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/geometry/projected_meters.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/graphics/pointf.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/graphics/rectf.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/gson/json_array.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/gson/json_element.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/gson/json_object.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/gson/json_primitive.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/i18n/collator.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/i18n/number_format.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/image.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/java/util.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/java_types.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/jni.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/jni_native.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/logger.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/logging_android.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/mapbox.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/map/camera_position.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/map/image.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/map_renderer.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/map_renderer_runnable.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/native_map_view.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/run_loop.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/snapshotter/map_snapshot.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/snapshotter/map_snapshotter.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/string_util.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/conversion/filter.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/conversion/position.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/conversion/transition_options.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/conversion/url_or_tileset.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/formatted.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/formatted_section.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/layers/background_layer.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/layers/circle_layer.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/layers/custom_layer.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/layers/fill_extrusion_layer.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/layers/fill_layer.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/layers/heatmap_layer.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/layers/hillshade_layer.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/layers/layer.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/layers/layer_manager.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/layers/line_layer.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/layers/raster_layer.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/layers/symbol_layer.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/light.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/position.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/sources/custom_geometry_source.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/sources/geojson_source.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/sources/image_source.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/sources/raster_dem_source.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/sources/raster_source.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/sources/source.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/sources/unknown_source.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/sources/vector_source.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/transition_options.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/style/value.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/text/local_glyph_rasterizer.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/gl_functions.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/thread.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/timer.cpp",
"vendor-android/mapbox-gl-native/platform/default/src/mbgl/gfx/headless_backend.cpp",
"vendor-android/mapbox-gl-native/platform/default/src/mbgl/gfx/headless_frontend.cpp",
"vendor-android/mapbox-gl-native/platform/default/src/mbgl/gl/headless_backend.cpp",
"vendor-android/mapbox-gl-native/platform/default/src/mbgl/map/map_snapshotter.cpp",
"vendor-android/mapbox-gl-native/platform/default/src/mbgl/text/bidi.cpp",
"vendor-android/mapbox-gl-native/platform/default/src/mbgl/util/compression.cpp",
"vendor-android/mapbox-gl-native/platform/default/src/mbgl/util/monotonic_timer.cpp",
"vendor-android/mapbox-gl-native/platform/default/src/mbgl/util/png_writer.cpp",
"vendor-android/mapbox-gl-native/platform/default/src/mbgl/util/thread_local.cpp",
"vendor-android/mapbox-gl-native/platform/default/src/mbgl/util/utf.cpp",
"vendor-android/mapbox-gl-native/platform/linux/src/headless_backend_egl.cpp"
],
"public_headers": {
"jni/string_conversion.hpp": "vendor-android/mapbox-gl-native/platform/default/include/jni/string_conversion.hpp",
"mbgl/gfx/headless_backend.hpp": "vendor-android/mapbox-gl-native/platform/default/include/mbgl/gfx/headless_backend.hpp",
"mbgl/gfx/headless_frontend.hpp": "vendor-android/mapbox-gl-native/platform/default/include/mbgl/gfx/headless_frontend.hpp",
"mbgl/gl/headless_backend.hpp": "vendor-android/mapbox-gl-native/platform/default/include/mbgl/gl/headless_backend.hpp",
"mbgl/map/map_snapshotter.hpp": "vendor-android/mapbox-gl-native/platform/default/include/mbgl/map/map_snapshotter.hpp"
},
"private_headers": {
"android_renderer_backend.hpp": "vendor-android/mapbox-gl-native/platform/android/src/android_renderer_backend.hpp",
"android_renderer_frontend.hpp": "vendor-android/mapbox-gl-native/platform/android/src/android_renderer_frontend.hpp",
"annotation/marker.hpp": "vendor-android/mapbox-gl-native/platform/android/src/annotation/marker.hpp",
"annotation/multi_point.hpp": "vendor-android/mapbox-gl-native/platform/android/src/annotation/multi_point.hpp",
"annotation/polygon.hpp": "vendor-android/mapbox-gl-native/platform/android/src/annotation/polygon.hpp",
"annotation/polyline.hpp": "vendor-android/mapbox-gl-native/platform/android/src/annotation/polyline.hpp",
"attach_env.hpp": "vendor-android/mapbox-gl-native/platform/android/src/attach_env.hpp",
"bitmap.hpp": "vendor-android/mapbox-gl-native/platform/android/src/bitmap.hpp",
"bitmap_factory.hpp": "vendor-android/mapbox-gl-native/platform/android/src/bitmap_factory.hpp",
"conversion/collection.hpp": "vendor-android/mapbox-gl-native/platform/android/src/conversion/collection.hpp",
"conversion/color.hpp": "vendor-android/mapbox-gl-native/platform/android/src/conversion/color.hpp",
"conversion/constant.hpp": "vendor-android/mapbox-gl-native/platform/android/src/conversion/constant.hpp",
"conversion/conversion.hpp": "vendor-android/mapbox-gl-native/platform/android/src/conversion/conversion.hpp",
"geojson/feature.hpp": "vendor-android/mapbox-gl-native/platform/android/src/geojson/feature.hpp",
"geojson/feature_collection.hpp": "vendor-android/mapbox-gl-native/platform/android/src/geojson/feature_collection.hpp",
"geojson/geometry.hpp": "vendor-android/mapbox-gl-native/platform/android/src/geojson/geometry.hpp",
"geojson/geometry_collection.hpp": "vendor-android/mapbox-gl-native/platform/android/src/geojson/geometry_collection.hpp",
"geojson/line_string.hpp": "vendor-android/mapbox-gl-native/platform/android/src/geojson/line_string.hpp",
"geojson/multi_line_string.hpp": "vendor-android/mapbox-gl-native/platform/android/src/geojson/multi_line_string.hpp",
"geojson/multi_point.hpp": "vendor-android/mapbox-gl-native/platform/android/src/geojson/multi_point.hpp",
"geojson/multi_polygon.hpp": "vendor-android/mapbox-gl-native/platform/android/src/geojson/multi_polygon.hpp",
"geojson/point.hpp": "vendor-android/mapbox-gl-native/platform/android/src/geojson/point.hpp",
"geojson/polygon.hpp": "vendor-android/mapbox-gl-native/platform/android/src/geojson/polygon.hpp",
"geojson/util.hpp": "vendor-android/mapbox-gl-native/platform/android/src/geojson/util.hpp",
"geometry/lat_lng.hpp": "vendor-android/mapbox-gl-native/platform/android/src/geometry/lat_lng.hpp",
"geometry/lat_lng_bounds.hpp": "vendor-android/mapbox-gl-native/platform/android/src/geometry/lat_lng_bounds.hpp",
"geometry/lat_lng_quad.hpp": "vendor-android/mapbox-gl-native/platform/android/src/geometry/lat_lng_quad.hpp",
"geometry/projected_meters.hpp": "vendor-android/mapbox-gl-native/platform/android/src/geometry/projected_meters.hpp",
"graphics/pointf.hpp": "vendor-android/mapbox-gl-native/platform/android/src/graphics/pointf.hpp",
"graphics/rectf.hpp": "vendor-android/mapbox-gl-native/platform/android/src/graphics/rectf.hpp",
"gson/json_array.hpp": "vendor-android/mapbox-gl-native/platform/android/src/gson/json_array.hpp",
"gson/json_element.hpp": "vendor-android/mapbox-gl-native/platform/android/src/gson/json_element.hpp",
"gson/json_object.hpp": "vendor-android/mapbox-gl-native/platform/android/src/gson/json_object.hpp",
"gson/json_primitive.hpp": "vendor-android/mapbox-gl-native/platform/android/src/gson/json_primitive.hpp",
"java/util.hpp": "vendor-android/mapbox-gl-native/platform/android/src/java/util.hpp",
"java_types.hpp": "vendor-android/mapbox-gl-native/platform/android/src/java_types.hpp",
"jni.hpp": "vendor-android/mapbox-gl-native/platform/android/src/jni.hpp",
"jni_native.hpp": "vendor-android/mapbox-gl-native/platform/android/src/jni_native.hpp",
"i18n/collator_jni.hpp": "vendor-android/mapbox-gl-native/platform/android/src/i18n/collator_jni.hpp",
"i18n/number_format_jni.hpp": "vendor-android/mapbox-gl-native/platform/android/src/i18n/number_format_jni.hpp",
"logger.hpp": "vendor-android/mapbox-gl-native/platform/android/src/logger.hpp",
"mapbox.hpp": "vendor-android/mapbox-gl-native/platform/android/src/mapbox.hpp",
"map/camera_position.hpp": "vendor-android/mapbox-gl-native/platform/android/src/map/camera_position.hpp",
"map/image.hpp": "vendor-android/mapbox-gl-native/platform/android/src/map/image.hpp",
"map_renderer.hpp": "vendor-android/mapbox-gl-native/platform/android/src/map_renderer.hpp",
"map_renderer_runnable.hpp": "vendor-android/mapbox-gl-native/platform/android/src/map_renderer_runnable.hpp",
"native_map_view.hpp": "vendor-android/mapbox-gl-native/platform/android/src/native_map_view.hpp",
"run_loop_impl.hpp": "vendor-android/mapbox-gl-native/platform/android/src/run_loop_impl.hpp",
"snapshotter/map_snapshot.hpp": "vendor-android/mapbox-gl-native/platform/android/src/snapshotter/map_snapshot.hpp",
"snapshotter/map_snapshotter.hpp": "vendor-android/mapbox-gl-native/platform/android/src/snapshotter/map_snapshotter.hpp",
"style/android_conversion.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/android_conversion.hpp",
"style/conversion/filter.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/conversion/filter.hpp",
"style/conversion/position.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/conversion/position.hpp",
"style/conversion/property_expression.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/conversion/property_expression.hpp",
"style/conversion/property_value.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/conversion/property_value.hpp",
"style/conversion/transition_options.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/conversion/transition_options.hpp",
"style/conversion/url_or_tileset.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/conversion/url_or_tileset.hpp",
"style/formatted.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/formatted.hpp",
"style/formatted_section.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/formatted_section.hpp",
"style/layers/background_layer.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/layers/background_layer.hpp",
"style/layers/circle_layer.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/layers/circle_layer.hpp",
"style/layers/custom_layer.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/layers/custom_layer.hpp",
"style/layers/fill_extrusion_layer.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/layers/fill_extrusion_layer.hpp",
"style/layers/fill_layer.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/layers/fill_layer.hpp",
"style/layers/heatmap_layer.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/layers/heatmap_layer.hpp",
"style/layers/hillshade_layer.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/layers/hillshade_layer.hpp",
"style/layers/layer.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/layers/layer.hpp",
"style/layers/layer_manager.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/layers/layer_manager.hpp",
"style/layers/line_layer.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/layers/line_layer.hpp",
"style/layers/raster_layer.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/layers/raster_layer.hpp",
"style/layers/symbol_layer.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/layers/symbol_layer.hpp",
"style/light.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/light.hpp",
"style/position.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/position.hpp",
"style/sources/custom_geometry_source.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/sources/custom_geometry_source.hpp",
"style/sources/geojson_source.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/sources/geojson_source.hpp",
"style/sources/image_source.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/sources/image_source.hpp",
"style/sources/raster_dem_source.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/sources/raster_dem_source.hpp",
"style/sources/raster_source.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/sources/raster_source.hpp",
"style/sources/source.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/sources/source.hpp",
"style/sources/unknown_source.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/sources/unknown_source.hpp",
"style/sources/vector_source.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/sources/vector_source.hpp",
"style/transition_options.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/transition_options.hpp",
"style/value.hpp": "vendor-android/mapbox-gl-native/platform/android/src/style/value.hpp",
"text/local_glyph_rasterizer_jni.hpp": "vendor-android/mapbox-gl-native/platform/android/src/text/local_glyph_rasterizer_jni.hpp"
}
}

View File

@@ -1,27 +0,0 @@
{
"//": "This file can be edited manually and is the canonical source.",
"sources": [
"vendor-android/mapbox-gl-native/platform/android/src/asset_manager_file_source.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/connectivity_listener.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/file_source.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/http_file_source.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/offline/offline_manager.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/offline/offline_region.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/offline/offline_region_definition.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/offline/offline_region_error.cpp",
"vendor-android/mapbox-gl-native/platform/android/src/offline/offline_region_status.cpp",
"vendor-android/mapbox-gl-native/platform/default/src/mbgl/storage/sqlite3.cpp"
],
"public_headers": {},
"private_headers": {
"asset_manager.hpp": "vendor-android/mapbox-gl-native/platform/android/src/asset_manager.hpp",
"asset_manager_file_source.hpp": "vendor-android/mapbox-gl-native/platform/android/src/asset_manager_file_source.hpp",
"connectivity_listener.hpp": "vendor-android/mapbox-gl-native/platform/android/src/connectivity_listener.hpp",
"file_source.hpp": "vendor-android/mapbox-gl-native/platform/android/src/file_source.hpp",
"offline/offline_manager.hpp": "vendor-android/mapbox-gl-native/platform/android/src/offline/offline_manager.hpp",
"offline/offline_region.hpp": "vendor-android/mapbox-gl-native/platform/android/src/offline/offline_region.hpp",
"offline/offline_region_definition.hpp": "vendor-android/mapbox-gl-native/platform/android/src/offline/offline_region_definition.hpp",
"offline/offline_region_error.hpp": "vendor-android/mapbox-gl-native/platform/android/src/offline/offline_region_error.hpp",
"offline/offline_region_status.hpp": "vendor-android/mapbox-gl-native/platform/android/src/offline/offline_region_status.hpp"
}
}

View File

@@ -68,7 +68,12 @@ global.propertyType = function propertyType(property) {
case 'boolean':
return 'Boolean';
case 'number':
return 'Float';
if (/bearing$/.test(property.name) &&
property.period == 360 &&
property.units =='degrees') {
return 'Double';
}
return /location$/.test(property.name) ? 'Double' : 'Float';
case 'formatted':
return 'Formatted';
case 'string':
@@ -79,7 +84,7 @@ global.propertyType = function propertyType(property) {
case 'color':
return 'String';
case 'array':
return `${propertyType({type:property.value})}[]`;
return `${propertyType({type:property.value, name: property.name})}[]`;
default:
throw new Error(`unknown type for ${property.name}`);
}
@@ -205,6 +210,11 @@ global.defaultValueJava = function(property) {
case 'boolean':
return 'true';
case 'number':
if (/bearing$/.test(property.name) &&
property.period == 360 &&
property.units =='degrees') {
return '0.3';
}
return '0.3f';
case 'formatted':
return 'new Formatted(new FormattedSection("default"))'
@@ -225,14 +235,16 @@ global.defaultValueJava = function(property) {
return 'new String[0]';
}
case 'number':
var result ='new Float[] {';
var isDouble = /location$/.test(property.name)
console.log(isDouble)
var result = 'new ' + (isDouble ? 'Double' : 'Float') + '[] {';
for (var i = 0; i < property.length; i++) {
result += "0f";
result += isDouble ? '0.0' : '0f';
if (i +1 != property.length) {
result += ", ";
result += ', ';
}
}
return result + "}";
return result + '}';
}
default: throw new Error(`unknown type for ${property.name}`)
}