Closed bleege closed 8 years ago
When getting ready to hook up the Geocoder I noticed that the TestApp is still running the old school (and deprecated) Mapbox Directions and Mapbox Geocoding libraries and not Mapbox Android Services as it should be these days. Before I can build the Location Picker I need to do a little house cleaning and get things ported to MAS.
I've got the basic UI of Location Picker built, namely pan map using a marker, select location, geocode location, display address with Marker and opened InfoWindow. To finish this part of the requirements off I need to:
Once these are done the next steps are to add the User Dot, User Dot animation, and Zoom events to be centered on Results Pin location.
/cc @zugaldia
Shortening the displayed geocoded data in the InfoWindow from the full address to simply the Street Number and Street Name makes the InfoWindow more manageable as well as better fit the use case. However, it also showed that fixing the empty snippet line is going to be a priority as well. This is documented in --> https://github.com/mapbox/mapbox-gl-native/issues/4959
Current status of the UI (see gif below). Next up is to get the marker to line up better between Search Mode and Display Mode. After that all that remains is the Over User Location animation and zoom to Display Pin gesture support.
Once a location is selected via Marker all zoom events should be centered on the Marker's location.
The code to make this happen is being picked up as a a part of focal point configuration in #4924 and PR'ed in #5332. After that lands you can rebase this branch on release-4.1.0
An animation should be triggered on the UserLocationView when the Marker is moved over it to indicate that the Marker and User Location have come into alignment.
I will create some example code so you can copy paste it into this one.
From this morning's team discussion here's the game plan for finishing this ticket:
Marker place is now good to go!
Picking up InfoWindow #4959 while waiting for #5332 to land.
Landed #5332 into release-android-v4.1.0
and will now integrated it into this branch.
Landed #4959 into release-android-4.1.0
and will work on integrating it along with #5332 next. @tobrun said he's got code for #4153 coming tomorrow.
Rebased onto release-android-v4.1.0
with #4959 and #5332 landed. Now time to hook things up.
Confirming that #4959 is working as needed.
Experimenting with the new Focal Point API from #5332 and it's not behaving as expected / needed. Specifically, it's not following the marker around after gesture has occurred. For example setting the initial focal point to the geocoded address (see code below) will work for the first gesture as long as the screen hasn't changed. This is because the Focal Point API was written to use Screen Coordinates (x and y) and not Geo Coordinates (Latitude and Longitude). In order to make this work for this use case the screen coordinate of the focal point would have to be updated to the marker's location on the screen every time the MapView
changes which is going to be very unwieldy for the developer using the SDK for this use case.
Example Code
Example Code In Action
Today's activities are going to be focused on the Focal Point Zoom and the pulsating UserLocationView. While earlier attempts produced similar functionality, they didn't meet the needs of this Use Case. I'm going to start first with the pulsating UserLocationView as that seems the closest to land.
Saving screenshot of View hierarchy used for MyUserLocationView's Canvas highlighted in gray and with image of selection marker's background highlighted in green.
The current status of the UI is that I've landed the math for determining when the Selection Marker passes over the MyLocationView
dot as well as disabled the Accuracy Ring on the MyLocationView
to make the animation to be performed more noticeable. (Please note that I'm not providing an animated gif for privacy reasons.) The question now is where to do the animation? Specifically, the MyLocationView
draws the user dot and accuracy itself directly onto the Canvas
using View.onDraw()
meaning that in order to provide an animation that stays in sync and properly aligns with the existing user dot it makes the most sense to do the animation there via a Drawable within the existing MyLocationView
class instead of being able to reuse the code from PR #5346 as it's entirely View
based. However, this likely means having to do a custom foreground or background drawable instead of being able to rely on the defaults. The only other option would be to extend the MyLocationView
API and I'm not keen on doing that at this time.
I'm going to keep exploring the MyLocationView
API and see if I can come up with a way around this.
I've tried creating a pulsating effect by replacing the the MyLocationView
foreground drawable with a VectorCompatDrawable so that I could use the ObjectAnimator
to animate it's scaleX
and scaleY
properties, however this didn't work as the Core GL renderer threw a ClassCastException.
// Source Code
VectorDrawableCompat userDot = (VectorDrawableCompat)getResources().getDrawable(R.drawable.ic_fiber_manual_record_black_24dp);
mapboxMap.getMyLocationViewSettings().setForegroundDrawable(userDot, userDot);
// Stacktrace
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV called with pending exception 'java.lang.ClassCastException' thrown in unknown throw location
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] in call to CallVoidMethodV
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] from void com.mapbox.mapboxsdk.maps.NativeMapView.nativeRender(long)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] | group="main" sCount=0 dsCount=0 obj=0x86213ef0 self=0xb4e07800
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] | sysTid=30552 nice=-11 cgrp=apps sched=0/0 handle=0xb6f2aec8
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] | state=R schedstat=( 1652472669 203359517 958 ) utm=140 stm=25 core=3 HZ=100
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] | stack=0xbe065000-0xbe067000 stackSize=8MB
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] | held mutexes= "mutator lock"(shared held)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] native: #00 pc 00004640 /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] native: #01 pc 00002e8d /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] native: #02 pc 00248381 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+68)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] native: #03 pc 0022cd0b /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+146)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] native: #04 pc 000b189b /system/lib/libart.so (art::JniAbort(char const*, char const*)+582)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] native: #05 pc 000b1fd5 /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+60)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] native: #06 pc 000b50e5 /system/lib/libart.so (art::ScopedCheck::ScopedCheck(_JNIEnv*, int, char const*)+1284)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] native: #07 pc 000bc59f /system/lib/libart.so (art::CheckJNI::CallVoidMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+30)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] native: #08 pc 0029b3f0 /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so (_JNIEnv::CallVoidMethod(_jobject*, _jmethodID*, ...)+124)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] native: #09 pc 0029f6c0 /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so (mbgl::android::NativeMapView::notifyMapChange(mbgl::MapChange)+240)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] native: #10 pc 004a5a3c /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so (mbgl::Map::render()+284)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] native: #11 pc 0029b500 /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so (mbgl::android::NativeMapView::render()+156)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] native: #12 pc 002f1fac /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so (???)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] native: #13 pc 002f20a4 /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so (???)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] native: #14 pc 002f203c /data/app/com.mapbox.mapboxsdk.testapp-1/lib/arm/libmapbox-gl.so (???)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] native: #15 pc 00000483 /data/data/com.mapbox.mapboxsdk.testapp/cache/slice-slice_6-classes.dex (Java_com_mapbox_mapboxsdk_maps_NativeMapView_nativeRender__J+90)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at com.mapbox.mapboxsdk.maps.NativeMapView.nativeRender(Native method)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at com.mapbox.mapboxsdk.maps.NativeMapView.render(NativeMapView.java:128)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at com.mapbox.mapboxsdk.maps.MapView.onDraw(MapView.java:1327)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.draw(View.java:16068)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.widget.FrameLayout.draw(FrameLayout.java:592)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.updateDisplayListIfDirty(View.java:14999)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.getDisplayList(View.java:15022)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.draw(View.java:15789)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.updateDisplayListIfDirty(View.java:14994)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.getDisplayList(View.java:15022)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.draw(View.java:15789)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.updateDisplayListIfDirty(View.java:14994)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.getDisplayList(View.java:15022)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.draw(View.java:15789)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.updateDisplayListIfDirty(View.java:14994)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.getDisplayList(View.java:15022)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.draw(View.java:15789)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.updateDisplayListIfDirty(View.java:14994)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.getDisplayList(View.java:15022)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.draw(View.java:15789)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.updateDisplayListIfDirty(View.java:14994)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.getDisplayList(View.java:15022)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.draw(View.java:15789)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewGroup.drawChild(ViewGroup.java:3678)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3472)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.draw(View.java:16071)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.widget.FrameLayout.draw(FrameLayout.java:592)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2916)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.updateDisplayListIfDirty(View.java:14999)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.View.getDisplayList(View.java:15022)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:275)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:281)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:320)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewRootImpl.draw(ViewRootImpl.java:2745)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2577)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2169)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1180)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6563)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.Choreographer.doCallbacks(Choreographer.java:590)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.Choreographer.doFrame(Choreographer.java:560)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.os.Handler.handleCallback(Handler.java:739)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.os.Handler.dispatchMessage(Handler.java:95)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.os.Looper.loop(Looper.java:145)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at android.app.ActivityThread.main(ActivityThread.java:5835)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at java.lang.reflect.Method.invoke!(Native method)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at java.lang.reflect.Method.invoke(Method.java:372)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
06-14 17:41:00.422 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/check_jni.cc:65]
06-14 17:41:00.842 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/verifier/method_verifier.cc:3343] Check failed: !Thread::Current()->IsExceptionPending()
06-14 17:41:00.842 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/runtime.cc:286] Runtime aborting --- recursively, so no thread-specific detail!
06-14 17:41:00.842 30552-30552/com.mapbox.mapboxsdk.testapp A/art: art/runtime/runtime.cc:286]
At the close of the day today, the two issues that still exist to resolve in order to complete this ticket are:
MyLocationView
when the selection marker is above it.
MyLocationView
determination logic has landed./cc @zugaldia @tobrun @ivovandongen @cammace
As discussed, @ivovandongen is running with this and possibly decoupling this example into 2 activities in the TestApp. One showing MyLocationView
and another one showing https://github.com/mapbox/mapbox-gl-native/pull/5346.
Example added via https://github.com/mapbox/mapbox-gl-native/pull/5391.
A common use case for apps is to have a Location Picker over a map and while the TestApp has the basics of this already in the
GeocoderActivity
it can be enhanced to mirror the functionality that traditionally is part of this use case as well as made more discoverable. Specifically, this example should have: