javascript - check the bounds changes in google map by touch event, in real time -


I want the touch event to change the border in Google map. In particular, I want to make some systems, if I show the Google map to the screen and change the boundary, then some can send a new map to the server by sending something. For the first time, I used the bound_changed event to remove this system. Such as

  google.maps.event.addListener (map, 'bounds_changed', (function () {var bar = map.getCenter () socket.emit ('center_spe', bar); }));   

It works in my laptop! If I drag the map with my mouse, Google Maps can send the variable in real time. But if I use a touch device, send Google Map "bar" when my touch ends.

Of course I checked the event list in the context of Google Map developer and I know there is no incident about touch event. Such as touch-mode, touchstream etc. ()

Can magic check the bound change in real time when I use touchscreen? Like below

  google.maps.event.addListener (map, "touchmov", function) {var bar = event.latLng; socket.emit ('message', bar);});   

(Of course there is no touch event in Google Maps event, the code above does not work)

, if you check on a touch device, you can see that once you drag the map, drag and dragstart Events are removed. When you drag the map, the drag event is removed repeatedly once you drag and drag the finger from the screen and both bounds_changed and Dragend events are removed, you can easily use the drag event for your purpose here is an example of how to use it: < Pre> google.maps.event.addListener (map, 'grab', function () {console.log ('drag end');});

Where Map is your map element if you consider using both bounds_upup and drag events Because there is no built-in method for implementing the listener for many events and still you do not want to define the callback - type two, you can:

  Google.maps.event.addListener (map, 'bounds_changed', function (e) {console.log ('bounded');}); Google.maps.event.addListener (map, 'dendend', function () {google.maps.event.trigger (this, 'bounds_changed');});   

bounds_changed is removed frequently on my PC when I drag the map (like drag event), but my mobile But Once I stop dragging the map and I remove my finger from the screen. On the other hand, the dragend event behaves similarly to both on my PC and mobile.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -