Hi, I used the view "Map (Leaflet) centered on visitor's location" that ships with this module. I converted it a bit and it looks and works like this.

visitor location

To reproduce this bug I will explain each screen number.

1. This is me when I visit my location in South Africa. It centers the map on my location.

2. I hoped on a plain to Auz to surprise this module creator with a bottle of red wine. He was not home, but the screenshot proves I was there.

3. Back home I grabed my tablet and forgot to turn the GPS on. This is where I experianced the bug the first time.
leaflet.js:Set map center and zoom first

The map cant find me on the tablet and it gives this error. This in turn breaks some js files that run after this js error. Or better explained by convenantd here when he spotted it:
https://www.drupal.org/node/2332603#comment-9120641

error

4. I get this "Your Location" screen when there is some IP's stored in IPGV&M but the system cant determine my location

Thanks for the default view "Map (Leaflet) centered on visitor's location". It has some settings that helps allot to figure out how to get a map centered on visitor location.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

RdeBoer’s picture

Hi @vlooivlerke,

Nice transformation of the "Map (Leaflet) centered on visitor's location" block!
How did you do that with the texts and colours of the buttons changing?
Have you become a gun programmer?
How do you distinguish between a location based on GPS (#1) and the fallback one, #4 (supposedly from an IP address-based source like Smart IP?).

To respond to your bug... Is it really?

Think about it... You are asking Leaflet to draw a map based on a single marker, but you are unable to provide the coordinates of the marker...
So what is Leaflet going to do? Automatically put you somewhere in SA? Or on the equator? Or on the North pole?
It does not have default. That's why it's complaining...

RE: the block... yes it is basically a superfast fake query that never returns any results and with no latitude and longitude fields specified for the map (as there aren't any returned).

Rik

vlooivlerke’s picture

Ok, first lets discuss the map problem.

In your module you offer:

No locations behaviour
a) Show empty map: enter latitude, longitude of the map center.
b) Show empty map centered on visitor location: enter the word visitor.
c) Show nothing: if this field is left blank, the map canvas will be suppressed when there are no locations to show. If you wish, you may use the No results behavior panel in the Advanced section of the Views UI to show an alternative text or content.

In my view I use option (b), but as a fallback I would like to use option (a), or if there is no marker data then it should fall back to option (c).

With no latitude and longitude fields specified for the map, how can this be better handled?

How do you distinguish between a location based on GPS (#1) and the fallback one, #4 (supposedly from an IP address-based source like Smart IP?).

I don't use Smart IP. It boggles my mind. I reproduce this easily. First I need to log into the site. Play around and make sure it knows my location. Then I will logout. This is when I get #4. It sets the map marker close to my location, but the button will indicate that there is no location found.

How did you do that with the texts and colours of the buttons changing?
Have you become a gun programmer?

I am not a gun programmer, more like a drupal module tail gunner.

To build a location block like this you need the following

1. IPGV&M - use the "Map (Leaflet) centered on visitor's location" to start with.
2. Install Views Conditional

3. Now add an "attachment" pane to the "Map (Leaflet) centered on visitor's location" block.
4. Add the "proximity" field (ships with geo field) and set the proximity to be calculated using your "HTML 5 Geo-coded Location" (that setting comes with your module)
5. Add a conditional field and set it to use the value of the proximity field.
6. Now set the validation to "If field-proximity is GREATER THAN 0.1" then output "Location Found" else "No location Found"

It works like this. If your location is known it will give you a proximity to a node that is greater than 0.1
If there is no location data available it will output a distance of 0.0

like the English say "There's more than one way to skin a cat.”
But I am sure this approach has given you a little chuckle.

Awaiting your wise words on a solution for map #3

Thanks

RdeBoer’s picture

Wow... nice piece of work with "Views Conditional"....

Re "First I need to log into the site. Play around and make sure it knows my location. Then I will logout. This is when I get #4."

Something that may go half way in explaining this is the fact that when you log out Drupal creates a new session and this is where your location is remembered.
So logging out means that you lose your location.
If you do not like this, you may want to install Session Cache API. It is able to remember session data across login/logout borders.

What I don't understand is that if you do not have a fallback like Smart IP or GeoIP installed you somehow still manage to get an approximate location, as shown in #4, without being prompted by the browser to "Share your (GPS/Wifi) location". Or maybe you ticked "Always accept". You could try this by clearing your browser history and then logging in, logging out and checking if your browser prompts you a second time to share the moment you log out.

Anyway... getting to the meat in the sandwich....
Rather than a) or b) or c), maybe the module should offer these compound choices:

c)

OR

a), falling back on c)

OR

b), falling back on a), falling back on c)

RdeBoer’s picture

Will consider this 7.x-1.27.

pookmish’s picture

I had this same issue where i'd prefer to center on the user location. But if no user location give, center on a desired point. My solution:
Change the "No locations behaviour' textfield into a select list as there are only 3 correct values.
Provide coordinate text fields for fallback behavior or specific centering.
Adjust map center coordinates when building map.

SocialNicheGuru’s picture

Status: Active » Needs review

I applied the patch
I selected "Center the map on the visitor's current location, at the specified zoom level."
for the no results.
Visitor location is selected for no location behavior
I put in the lat/lon for San Francisco CA.

While there are objects on the map, the user location could not be found.

It did not goto the lat/lon I entered.

Status: Needs review » Needs work

The last submitted patch, 5: ip_geoloc-set_map_center-2334609.patch, failed testing.