Hi,
I have a geolocated classic view that is supposed to show events within 50 km from the user location, without a map. The view triggers the browser position tracking window, but even though the user selects ALLOW the view displays the message "Your location is needed to show this content.". BUT if I add whatever map to the same page of the view then also the view displays its output correctly (and cannot go back to trigger the position tracking window, it stays selected even deleting cookes, etc).
It looks like showing a map on the page is mandatory to get the geolocation fully working. Is this true or is there anything I don't understand ? In this view I have added [wpv-geolocation] like this:
[wpv-geolocation]
[wpv-layout-meta-html]
[/wpv-geolocation]
Is this correct ?
I also have another similar NOT geolocalized view, showing all events. I'd like to display the output of the geolocalized one if the user allows his position tracking OR the other not-geolocalized one if the user blocks the tracking, how do I test the user selection before the content is shown on the page? I tried with conditionals, they work but the browser position tracking window doesn't show up anymore.
Please let me know
thanks
Regards
Nicola
When the "[wpv-geolocation]" shortcode is used, "Your location is needed to show this content." message is shown, until the visitor agrees to share location information.
The following screenshots show how this consent dialog appears in different browsers:
- Chrome: hidden link
- Firefox: hidden link
- Internet Explorer: hidden link
[wpv-geolocation]
[toolset-maps-distance-conditional-display location='Spain' distance='100' display="inside" unit='mi']
Show content to visitor who is inside the 1000 miles radius from Spain's central location.
[/toolset-maps-distance-conditional-display]
[/wpv-geolocation]
Hello Minesh,
You wrote: When the "[wpv-geolocation]" shortcode is used, "Your location is needed to show this content." message is shown, until the visitor agrees to share location information.
Ok, but what happens in my case is that the message is shown also if the visitor agrees, UNLESS a map is shown on the page.
toolset-maps-distance-conditional-display "Shows or hides its content based on the distance of the current visitor from the given point", but this isn't what I am looking for. I need to show content based on the Agree/Block selection in the consent window. If he agrees I show the geolocated content, if not just a generic content.
function func_get_maps_location_cookie() {
if (!isset($_COOKIE["toolset_maps_location"]) or (isset($_COOKIE["toolset_maps_location"]) and $_COOKIE["toolset_maps_location"]=='')) {
return 0;
}
return 1;
}
add_shortcode( 'get-location-cookie', 'func_get_maps_location_cookie' );
Where:
- Please replace view-distance-filter with your original view slug.
By default - it will show all the content from view but as soon as you accept the location sharing consent, it will display the filtered result based on your location.
Hello Minesh,
I implemented your solution, just renamed it as [geolocation-test]. What happens is that the consent window is always triggered but:
- if I select BLOCK: [geolocation-test] returns 0 and the NOT geolocalized view is never shown. If I open another geolocated page (without this conditional) it correctly detects that the position tracking is not allowed and the map is not shown.
- if I select CONSENT: [geolocation-test] still returns 0 with the message "Your location is needed to show this content", the page reloads but [geolocation-test] still returns 0. If I open another geolocated page (without this conditional) it correctly detects that the position tracking is allowed and the map is shown.
The page where these views are supposed to be shown is my homepage. I have created another test page and added the same code, this ALWAYS returns 1, no matter what consent! this doesn't make much sense to me. Any clue ?
Can you please clear all the cache and then try to disable the plugin and then also clear all cookies and start testing from first and check how it goes?
Hello Minesh,
I tried many solutions, but I see this test/conditional is a never ending mess, results change every time due to caching and possibly to other geolocated elements on the page which can conflict. In order not to waste your time, I decided to go for a different solution that always work: show the non geolocated view to loggedout users and the geolocated view to loggedin users. This is possible thanks to blocks visibility rules. If under other circumstances you can find way to show content depending on consent please publish a document so that everyone can benefit.
Thanks and regards
Nicola