Needs review
Project:
Leaflet Widget for Geofield
Version:
7.x-2.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
17 Jun 2015 at 12:49 UTC
Updated:
17 Dec 2018 at 21:12 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
robertwb commentedI am proposing a basic patch here using the Leaflet modules internal locate method. This does geolocate (works on mobile and desktop). I think that it is not the cleanest way to do it, though the assumption probably works 99.99% of the time. Basically, I patched the js file:
Comment #2
robertwb commentedComment #3
abdolmaleki commentedHow to add a marker
Comment #4
sano commentedhmm, this did not work for me. After patching/clearing cache and refreshing the node/add form where the map is used I would expect the browser to ask me for permission to allow geolocate me, but this is not happening and map is not centered to may location. The settings for the field are shown in the attached screenshot.
Comment #5
Joel MMCC commented@sano #4, first, remove the default latitude and longitude, or set them to 0, 0. As stated in the comment with the patch, it works by checking for 0, 0, and if it’s not set there, it assumes that there is existing geometry and doesn’t attempt to geolocate since that would erase the existing data.
Also be sure that your website is being served via SSL (https protocol). As part of the drive to increase privacy, all modern browsers on all platforms now silently reject attempts to geolocate the user that come over unencrypted http — without an error message displayed to the user or even asking for their permission. You’d only see the error in the Javascript Console of your browser’s Developer Tools.
For development purposes you can use a self-signed SSL certificate, but for production sites use a real one. Let’s Encrypt now issues free certificates suitable for non-e-commerce uses, and many hosting providers now integrate that so that installing one can be done easily from the hosting control panel. They even auto-renew every 90 days for extra security.
I recommend all sites do this anyway, even if you don’t need HTML5 Geolocation. Google and other search engines are starting to mark all unencrypted http sites as unsafe, same as if your site had gotten hacked and was distributing malware! Also, of course, if your site isn’t encrypted, then every time you log in, you’re sending your admin login credentials over the Internet in a highly insecure manner.