fnicollet / Leaflet

:leaves: JavaScript library for mobile-friendly interactive maps
http://leafletjs.com
BSD 2-Clause "Simplified" License
48 stars 20 forks source link

Added window.orientation to CompassBearing.js #5

Closed itbeyond closed 8 years ago

itbeyond commented 8 years ago

To handle mobile device rotation added window.orientation to the setBearing function. Increased the throttle time to 1000 (1s) produces better visual display on mobile device.

fnicollet commented 8 years ago

Thanks for this PR. I am wondering about the window.orientation bit. Did you try it on a device? It seems like it has different values depending on the device (I tested on Android), see: https://notes.matthewgifford.com/a-misconception-about-window-orientation-7231235a94c2#.ktos43e2y

itbeyond commented 8 years ago

Tested on Android 5.0.1 Samsung S4 so far - will go full full testing shortly including iOS in the next day or so.

fnicollet commented 8 years ago

ok, was it a problem when on landscape mode? Maybe I haven't tried that

On Thu, Sep 15, 2016 at 12:24 PM, David Martin notifications@github.com wrote:

Tested on Android 5.0.1 Samsung S4 so far - will go full full testing shortly including iOS in the next day or so.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fnicollet/Leaflet/pull/5#issuecomment-247291847, or mute the thread https://github.com/notifications/unsubscribe-auth/ABLtoWY4n2Ta-9dzLwprz-bfx7kUfdtiks5qqRzzgaJpZM4J9tHC .

Fabien Nicollet Tel : +33 (0)6 60 54 72 20

itbeyond commented 8 years ago

I have tested it in all 4 positions and it works fine. I may find other devices do strange stuff before I release but my usage is within a Cordova/Ionic app using crosswalk so forces Chrome on Android and uses Safari on iOS.

fnicollet commented 8 years ago

Hello,

Just merged this commit and trying on my phone with the example: https://rawgit.com/fnicollet/Leaflet/rotate-master/debug/rotate/rotate-mobile.html

When in portrait mode on my phone (Android 4.something), it works well: the map is pointing to the direction that my phone is pointed at. When in landscape, I am not sure about the behaviour that I see. To me, the map is not rotate properly (in "both" landscape modes, +90 and -90). I guess the map should still point to the direction that my phone is pointed at (the top of the side of my phone?), but it is not the case.

Can you give it a go please? Fabien