Skip Navigation

[Resolved] Showing user locations on map

This support ticket is created 4 years, 7 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 1 replies, has 2 voices.

Last updated by Waqar 4 years, 7 months ago.

Assisted by: Waqar.

Author
Posts
#1834053

Hi Waqar!

I want to know if it is possible to create a map with Toolset Maps to have a dynamic map of the location of our registered users

#1835277

Hi,

Thank you for waiting and here are the steps to create a user view that shows each user's location on the map:

1. For this example, suppose that there are two single-line user fields for the city (user-city) and the country (user-country) and you'd like to show a list of all users with the "subscriber" role.

2. From WP Admin -> Toolset -> Views, please create a new view and set it to show the users with the subscriber role.
( screenshot: hidden link )

3. In the "Loop Editor" section, you'll include the shortcode for the map, map marker, and for any fields, that you'd like to show:
( screenshot: hidden link )

For example:


[wpv-layout-start]
	[wpv-items-found]
	[wpv-map-render map_id="map-1"][/wpv-map-render]
	<!-- wpv-loop-start -->
	<ol class="wpv-loop js-wpv-loop">
		<wpv-loop>
			<li>
				Name: [wpv-user field="display_name"]<br>
				City: [types usermeta="user-city"][/types]<br>
				Country: [types usermeta="user-country"][/types]
				[wpv-map-marker map_id='map-1' marker_id='marker-2' address='[types usermeta="user-city"][/types], [types usermeta="user-country"][/types]'][/wpv-map-marker]
				<hr>
			</li>
		</wpv-loop>
	</ol>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

Please note how I've used the values from the user's city and the country fields to pass on the "address" attribute value, in the "wpv-map-marker" shortcode:
https://toolset.com/documentation/programmer-reference/maps/maps-shortcodes/#wpv-map-marker

4. After that, you can insert this newly created view on your page, using the shortcode:
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-view )


[wpv-view name="user-view"]

And this is how the view shows on the front-end:
Screenshot: hidden link

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar