Skip Navigation

[Resolved] Google map/ current location visitor / focused on that location / no items found

This support ticket is created 5 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 8 replies, has 3 voices.

Last updated by Christian Cox 5 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1250071
Schermafbeelding 2019-05-26 om 09.24.19.jpg
Schermafbeelding 2019-05-26 om 09.29.20.jpg
Schermafbeelding 2019-05-26 om 09.23.15.jpg
Schermafbeelding 2019-05-26 om 09.23.35.jpg

Tell us what you are trying to do?
1) I would like to show the current location of the visitor on a map with a marker. When the page opens the map should be focused on this marker within a zoom distance of about 150km around this marker, BUT if there aren't any results within this 150km it should be more km's towards the first result that is nearest.

2) Above the map I have the 'show results within' filter where a visitor can introduce km and his location by filling in an address or use the button 'use my location'. This filter is necessary in case the visitor doesn't agree with the browser using it's location. BUT when the visitor does agree, it's location should already be filled in these filters (this seems logical).

3) I would like to at least show the whole map when there are no results instead of 'no items found'.

It works sometimes, but not very fluently, it all needs to be much more steady.

This is my view (which is used inside a wordpress archive):
It's a view for custom search
1 post type selected
See the other screenshots

#1250413

3) I would like to at least show the whole map when there are no results instead of 'no items found'.
Move the wpv-map-render shortcode to be above the wpv-items-found shortcode in the Loop Editor. Then your map will display regardless of the number of items found. If you want to hide the "No items found" message, delete that message text from the Loop Editor.

It works sometimes, but not very fluently, it all needs to be much more steady.
May I see it on your site so I can try to replicate the problems? Please provide login credentials in the private reply fields here, and let me know where I can find the map.

#1251369

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Bart,

Christian is currently off on holidays today but will be back tomorrow to continue with you on this.

Thanks for the patience.

#1252203

When the page opens the map should be focused on this marker within a zoom distance of about 150km around this marker, BUT if there aren't any results within this 150km it should be more km's towards the first result that is nearest.
The basic options offered here are:
1. Specify an initial static center point and zoom level, regardless of the results found.
2. Instruct the map to zoom out when the page loads, far enough to display all the markers on the map.
3. Write custom JavaScript to manipulate the map zoom level as needed. If you're a JavaScript developer you can find some extra information about interacting with map objects here: https://toolset.com/documentation/user-guides/programmatically-change-map-settings/
I think your suggestion to zoom out enough to display at least one result is useful, but it's not currently offered. If you'd like to request that added to the software, I encourage you to submit your request here: https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
That will put your request in front of key decision makers who influence upcoming features.

2) ...BUT when the visitor does agree, it's location should already be filled in these filters (this seems logical).
The issue here is that the initial browser notification and agreement is not linked to the action of clicking "Use my location" in the custom search. The initial agreement is displayed because you have used the wpv-geolocation shortcodes to wrap specific content in the loop template. This wrapper shortcode triggers the browser notification and request for location access immediately when the page first loads (if someone has not yet visited the site and approved or blocked location access). Is it necessary to include these geolocation shortcodes here, or is this just a test of some kind? I'm not clear what your requirements are for the map so I need more information about what you want to accomplish with this code:

[wpv-geolocation][wpv-map-marker map_id="map-1" marker_id="marker-1" marker_title="This is a marker" id="[wpv-post-id]" marker_icon='[wpv-post-body view_template="map-markers"]' marker_field="wpcf-address" fitbounds="off" single_zoom="8"]<strong>[wpv-post-title]</strong><hr><a class="flolink" href="[wpv-post-url]">view this [wpv-post-type show="single"]</a>[/wpv-map-marker][/wpv-geolocation]
#1254137

Ok I simplified the whole idea, to be able to achieve the closest thing possible.

Showing the whole map when blocking the use of the visitor's location seems to work. So that is solved. But when I try to enter an address or 'use my location', the location browserpopup does not appear again. Maybe once the visitor has clicked 'block' this is saved in the browser, so going back to agreeing on a location seems to be on the visitor's side, that I can understand.

But the following things seem logical to work:
- When entering the archive page the visitor can agree using his/ her location. Let's say they agree.
- Than the map shows it's location. This works.
- It doesn't matter if there aren't any posts within the zoom range.
- BUT when I start to zoom out, there should be post markers visible but they do not show since I've chosen to only 'load' posts within a certain range based on the user's location, so first question:
- How to show all posts, but still start off zoomed in on the marker of the current location of the visitor?

If the visitor did agree using his/ her location and wants to change the location, the option exists to introduce an address or use the button 'use my location'. But this doesn't work. Either entering an address or directly use the button 'use my location' show the west coast of Africa. I already deleted cached locations and checked if Geocoding is enabled in the google console and it is.

So:
1. How to show all posts, but still start off zoomed in on the marker of the current location of the visitor?
2. Why do I see the west coast of Africa when I enter an address or use the 'use my location' button?

Question 1 seems like a logical function and question 2 seems like some sort of error.

It's about the same page, so the login data is the same.

#1255557

Hi Christian,

Did you see my last message?

#1256851

Is this topic closed? it's been 4 days!

#1257045

Hello, the topic is not closed. I am working my way through my queue and will respond in turn. Thanks for your patience.

#1257563

- How to show all posts, but still start off zoomed in on the marker of the current location of the visitor?
This specific combination of configurations isn't offered by the current system. You can choose an arbitrary pair of lat/long coordinates as the static center, or you can instruct the map to zoom out and show all the markers (see zoom.png). With custom code, you can zoom and pan the map programmatically.

2. Why do I see the west coast of Africa when I enter an address or use the 'use my location' button?
This behavior typically indicates no results are found within the specified radius from the address or location used by the filter. Is this the case when you are testing? If no results are found when the map refreshes, the center position is reset to 0' latitude and 0' longitude. This is why you see the west coast of Africa. Some people choose to hide the map when no results are found. Others use custom JavaScript to programmatically reset the center position based on other criteria.