-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not finding location in Chrome & Firefox for Mobile #334
Comments
I am also facing this issue in ios webview |
I'm facing this same issue. The demo website ( https://domoritz.github.io/leaflet-locatecontrol/demo/ ) works on Android when using Chrome, and work on iOS when using Safari, but does not work on iOS when using Chrome. I've noticed that when it works two messages are displayed: And when it doesn't work, when using the Chrome browser on an iOS device, only one message is displayed: |
Same issue here. Have you figured this out ? |
@tchercheuse - I decided to create a custom Leaflet control that allows users to locate their position on the map using the browser's geolocation capabilities. `
}); map.addControl(new L.Control.UserLocation()); Here's how it works: L.Control.UserLocation = L.Control.extend({ ... });: This code defines a new Leaflet control called UserLocation by extending the L.Control class. It means that this custom control will inherit properties and methods from the L.Control class, making it function like any other built-in control in Leaflet. The options object contains configuration properties for the control. In this case, it defines the position of the control on the map (bottom right) and the title displayed as a tooltip on the control button. The addListener method from L.DomEvent is used to prevent the default behavior of clicks on the control, which avoids any unintended side effects.
The first argument is a success callback function that will be called with the user's updated position. The second argument is an error callback function that will be called if there is an error retrieving the user's location. The third argument is an options object, where you can enable high accuracy to get more precise results from the geolocation API. Inside the success callback function, the user's latitude and longitude are extracted from the geolocation API's position.coords, and a new L.LatLng object is created from them. Then, the _userMarker's position is updated with the new coordinates, and the map is panned to center on the user's updated location. If geolocation is not supported by the user's browser, an error message is logged to the console. The custom control is added to the map using map.addControl(new L.Control.UserLocation());. |
Thanks, we'll test that after holidays ;) |
Locator is not finding a location on either Chrome or Firefox for mobile, just spins and spins, no errors or anything
The text was updated successfully, but these errors were encountered: