MapView Drag end event.

(I use google translate. Please understand even if it is awkward.)

Currently, we are testing with Android.

Dragging end the touch, we are in the process of reloading nearby stores from a new location.

Setting the value of Latitude, Longtude in MapView to Observable did not correctly confirm the end of the drag.

I try used Tapped or WhilePressed or etc… in MapView.
but it was executed in Local, but it does not work on device.

I saw article that it was taking events from Android.
(https://www.fusetools.com/community/forums/bug_reports/getting_click_events_from_element_on_top_of_map_vi)

How do I check the end of a drag on Android?

I hope I’m understanding you right; what you need is to “do something when a map is moved”.

If so, using data-bound observables to Latitude and Longitude properties on MapView seems to be the right approach. I’m not sure what the problems you encountered were, so you should have shown some of your code.

Here’s something that I made as a proof of concept, and it works as expected:

<App>
    <JavaScript>
    var Observable = require("FuseJS/Observable");
    var lat = Observable(0);
    var lon = Observable(0);
    var combined = lat.combineLatest(lon, function(latitude, longitude) {
        return {latitude: latitude, longitude: longitude};
    });
    combined.onValueChanged(module, function(obj) {
        console.log("coordinates have changed.");
        console.log("latitude: " + obj.latitude);
        console.log("longitude: " + obj.longitude);
    });
    module.exports = {
        lat: lat,
        lon: lon
    };
    </JavaScript>
    <NativeViewHost>
        <MapView Latitude="{lat}" Longitude="{lon}" />
    </NativeViewHost>
</App>

Hope this helps!

Thank you.

However, this method continues to fire events while dragging.

I want an event only when the drag ‘end’ (touch up).

My testing shows that the observables are only updated when you release the pointer (finger). Which is “drag end”.

If you see different behaviour, please share more details on what device you are testing on, describe exactly what is happening, and what you expect to happen instead.

Really? I tested this source! :frowning:

When dragging is paused (just stop finger), combineLatest is executed.

We hope when ‘finger up’!!!

I just re-tested this on both iOS and Android 6, and it only updates coordinates when I lift the finger (not when I just stop dragging).

As I said above: ff you see different behaviour, please share more details on what device you are testing on, describe exactly what is happening, and what you expect to happen instead.

os : windows 10

fusetools : v 1.3.0

mobile : LG G Pro, android ver 5.0.1

The source is the same except for the router and the coordinates and Zoom.

OnValueChanged is not performed while dragging the map.

However, it will be executed when finger pause.

Also, at the moment of raising the finger, the log is shot twice.

This seems to be all I can explain.

and, source

<Panel ux:Class="Test2Page">
	<Router ux:Dependency="router" />
	<JavaScript>
    var Observable = require("FuseJS/Observable");
    var lat = Observable(35.166677); // this point is our company ( busan, south korea )
    var lon = Observable(129.133914);
    var combined = lat.combineLatest(lon, function(latitude, longitude) {
        return {latitude: latitude, longitude: longitude};
    });
    combined.onValueChanged(module, function(obj) {
        console.log("coordinates have changed.");
        console.log("latitude: " + obj.latitude);
        console.log("longitude: " + obj.longitude);
    });
    module.exports = {
        lat: lat,
        lon: lon
    };
    </JavaScript>
    <NativeViewHost>
        <MapView Latitude="{lat}" Longitude="{lon}" />
    </NativeViewHost>
</Panel>

The callback is fired twice because there are two Observables that change. So that’s expected. You could delay the polling for new data to work around this.

Unfortunately I don’t have an Android 5 device at hand, so I can’t test what you’re reporting about the “finger pause”. Would it be possible for you to check if the behaviour is different on different Android versions?

I have rented and tested the Samsung Galaxy s6.
The android version is 7.0

But the same problem continues.

Is there any other way not to use Observable?

thank you for your reply! :slight_smile:

By compiling on a Mac,

When tested with the iPhone, it works fine.

But it also does not work as expected on Android.