Implement icon-anchor property

This commit is contained in:
Lauren Budorick
2017-08-28 13:32:56 -07:00
committed by GitHub
parent c6ab20e5c6
commit 2de89a99bc
27 changed files with 558 additions and 122 deletions

View File

@@ -58,15 +58,15 @@ struct Converter<jni::jobject*, mbgl::style::IconTextFitType> {
};
template <>
struct Converter<jni::jobject*, mbgl::style::TextJustifyType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::TextJustifyType& value) const {
struct Converter<jni::jobject*, mbgl::style::SymbolAnchorType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::SymbolAnchorType& value) const {
return convert<jni::jobject*, std::string>(env, toString(value));
}
};
template <>
struct Converter<jni::jobject*, mbgl::style::TextAnchorType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::TextAnchorType& value) const {
struct Converter<jni::jobject*, mbgl::style::TextJustifyType> {
Result<jni::jobject*> operator()(jni::JNIEnv& env, const mbgl::style::TextJustifyType& value) const {
return convert<jni::jobject*, std::string>(env, toString(value));
}
};

View File

@@ -109,6 +109,41 @@ namespace conversion {
}
}
// icon-anchor
inline std::string toString(mbgl::style::SymbolAnchorType value) {
switch (value) {
case mbgl::style::SymbolAnchorType::Center:
return "center";
break;
case mbgl::style::SymbolAnchorType::Left:
return "left";
break;
case mbgl::style::SymbolAnchorType::Right:
return "right";
break;
case mbgl::style::SymbolAnchorType::Top:
return "top";
break;
case mbgl::style::SymbolAnchorType::Bottom:
return "bottom";
break;
case mbgl::style::SymbolAnchorType::TopLeft:
return "top-left";
break;
case mbgl::style::SymbolAnchorType::TopRight:
return "top-right";
break;
case mbgl::style::SymbolAnchorType::BottomLeft:
return "bottom-left";
break;
case mbgl::style::SymbolAnchorType::BottomRight:
return "bottom-right";
break;
default:
throw std::runtime_error("Not implemented");
}
}
// text-justify
inline std::string toString(mbgl::style::TextJustifyType value) {
switch (value) {
@@ -126,41 +161,6 @@ namespace conversion {
}
}
// text-anchor
inline std::string toString(mbgl::style::TextAnchorType value) {
switch (value) {
case mbgl::style::TextAnchorType::Center:
return "center";
break;
case mbgl::style::TextAnchorType::Left:
return "left";
break;
case mbgl::style::TextAnchorType::Right:
return "right";
break;
case mbgl::style::TextAnchorType::Top:
return "top";
break;
case mbgl::style::TextAnchorType::Bottom:
return "bottom";
break;
case mbgl::style::TextAnchorType::TopLeft:
return "top-left";
break;
case mbgl::style::TextAnchorType::TopRight:
return "top-right";
break;
case mbgl::style::TextAnchorType::BottomLeft:
return "bottom-left";
break;
case mbgl::style::TextAnchorType::BottomRight:
return "bottom-right";
break;
default:
throw std::runtime_error("Not implemented");
}
}
// text-transform
inline std::string toString(mbgl::style::TextTransformType value) {
switch (value) {

View File

@@ -125,6 +125,12 @@ namespace android {
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconAnchor(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconAnchor());
return jni::Object<jni::ObjectTag>(*converted);
}
jni::Object<jni::ObjectTag> SymbolLayer::getIconPitchAlignment(jni::JNIEnv& env) {
using namespace mbgl::android::conversion;
Result<jni::jobject*> converted = convert<jni::jobject*>(env, layer.as<mbgl::style::SymbolLayer>()->SymbolLayer::getIconPitchAlignment());
@@ -520,6 +526,7 @@ namespace android {
METHOD(&SymbolLayer::getIconPadding, "nativeGetIconPadding"),
METHOD(&SymbolLayer::getIconKeepUpright, "nativeGetIconKeepUpright"),
METHOD(&SymbolLayer::getIconOffset, "nativeGetIconOffset"),
METHOD(&SymbolLayer::getIconAnchor, "nativeGetIconAnchor"),
METHOD(&SymbolLayer::getIconPitchAlignment, "nativeGetIconPitchAlignment"),
METHOD(&SymbolLayer::getTextPitchAlignment, "nativeGetTextPitchAlignment"),
METHOD(&SymbolLayer::getTextRotationAlignment, "nativeGetTextRotationAlignment"),

View File

@@ -59,6 +59,8 @@ public:
jni::Object<jni::ObjectTag> getIconOffset(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconAnchor(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getIconPitchAlignment(jni::JNIEnv&);
jni::Object<jni::ObjectTag> getTextPitchAlignment(jni::JNIEnv&);