diff options
author | Dmitry Yunitsky <yunik@mapswithme.com> | 2014-07-31 18:36:27 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:23:22 +0300 |
commit | 7a704babd830ba23de4d9f61e47586d7e646f0f9 (patch) | |
tree | 82a79615caebc9ae4f5a1e2603530ad5c7df4af5 /android/jni/com/mapswithme/maps/Framework.cpp | |
parent | 45248f35a24edc29c0a0ca652e3bdfc4bd627dfa (diff) |
Jni methods modifications.
Diffstat (limited to 'android/jni/com/mapswithme/maps/Framework.cpp')
-rw-r--r-- | android/jni/com/mapswithme/maps/Framework.cpp | 47 |
1 files changed, 45 insertions, 2 deletions
diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index 5973d88295..e9979803b1 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -176,11 +176,19 @@ namespace android return m_work.GetCountryStatusDisplay(); } - void Framework::ShowCountry(storage::TIndex const & idx) + void Framework::ShowCountry(storage::TIndex const & idx, bool zoomToDownloadButton) { m_doLoadState = false; - m_work.ShowCountry(idx); + if (zoomToDownloadButton) + { + m2::RectD const rect = m_work.GetCountryBounds(idx); + double const lon = MercatorBounds::XToLon(rect.Center().x); + double const lat = MercatorBounds::YToLat(rect.Center().y); + m_work.ShowRect(lat, lon, 10); + } + else + m_work.ShowCountry(idx); } storage::TStatus Framework::GetCountryStatus(storage::TIndex const & idx) const @@ -1127,4 +1135,39 @@ extern "C" UserMark const * mark = fr->GetUserMark(pxPoint, true); fr->GetBalloonManager().OnShowMark(mark); } + + JNIEXPORT jstring JNICALL + Java_com_mapswithme_maps_Framework_nativeGetCountryNameIfAbsent(JNIEnv * env, jobject thiz, + jdouble lat, jdouble lon) + { + string const name = g_framework->GetCountryNameIfAbsent(MercatorBounds::FromLatLon(lat, lon)); + + return (name.empty() ? 0 : jni::ToJavaString(env, name)); + } + + JNIEXPORT jstring JNICALL + Java_com_mapswithme_maps_Framework_nativeGetViewportCountryNameIfAbsent(JNIEnv * env, jobject thiz) + { + string const name = g_framework->GetCountryNameIfAbsent(g_framework->GetViewportCenter()); + return (name.empty() ? 0 : jni::ToJavaString(env, name)); + } + + JNIEXPORT jobject JNICALL + Java_com_mapswithme_maps_Framework_nativeGetCountryIndex(JNIEnv * env, jobject thiz, + jdouble lat, jdouble lon) + { + storage::TIndex const idx = g_framework->GetCountryIndex(lat, lon); + + // Return 0 if no any country. + if (idx.IsValid()) + return storage::ToJava(idx); + else + return 0; + } + + JNIEXPORT void JNICALL + Java_com_mapswithme_maps_Framework_nativeShowCountry(JNIEnv * env, jobject thiz, jobject idx, jboolean zoomToDownloadButton) + { + g_framework->ShowCountry(storage::ToNative(idx), (bool) zoomToDownloadButton); + } } |