I want map be centralized on the current location of the user. I did not find how to do it.
I saw there are the attributes "general_center_lat" and "general_center_lon" to centralize the map given latitude and longitude. So, the question is how can I retrieve the current user location to fill out these attributes ?
Hello, the feature to automatically center the map based on the visitor's location when the map loads is not available, but you can display a marker at the visitor's current location and use the Focus on Marker shortcode to generate a text link that will allow visitors to center the map on their location: https://toolset.com/documentation/user-guides/maps-shortcodes/#map-focus-on-marker
The User's location is not publicly available through any API at this time. You're welcome to submit new feature requests if you'd like to see these ideas added in an upcoming version of the Toolset suite:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
I did not understand: text link that allow to center the map ? What you mean "text link" ?
I made an example you can see here:
https://christiancox-22119-rel-1.discover-wp.com/focus-on-marker-test/
The browser will ask for permission to use your location. You MUST allow location access to see the example working. Click "FOCUS ON MY LOCATION" after both markers are shown. There should be one marker at Washington DC, USA, and another at your current location. When you click "FOCUS ON MY LOCATION" the map should zoom to your location.
First, you will create a Marker that displays at the User's location. Check this document for more information: https://toolset.com/documentation/user-guides/display-on-google-maps/displaying-markers-on-google-maps/#displaying-current-visitor-location
Then you can use the "Focus on Marker" feature to generate a text link. See the screenshot here. The text link can say something like "FOCUS ON MY LOCATION". When the User clicks this link, the map will focus on their location.
The documentation for this shortcode is here: https://toolset.com/documentation/user-guides/maps-shortcodes/#map-focus-on-marker
Here is the code I used to display the map, the two map markers, and the focus on marker text link:
[wpv-map-render map_id="map-test-focus" map_height="500px"][/wpv-map-render]
[wpv-map-marker map_id='map-test-focus' marker_id='marker-user-focus' map_render='wait' current_visitor_location='true'][/wpv-map-marker]
[wpv-map-marker map_id='map-test-focus' marker_id='marker-other-address' address='1600 Pennsylvania Avenue Northwest, Washington, DC, USA'][/wpv-map-marker]
<a href="#" class="js-wpv-addon-maps-focus-map" data-map="map-test-focus" data-marker="marker-user-focus">FOCUS ON MY LOCATION</a>
Let me know if you have questions about this.