Hi Team,
if have a form with some search options like
<input type="text" ...
<input type="radio" ...
<input type="checkbox" ...
After that i render a map via
echo do_shortcode('[wpv-map-render map_id="my-map" map_height="50vh" cluster="on" cluster_max_zoom="12" street_view_control="off" map_type_control="off"][/wpv-map-render]');
And i have a wp_query loop to echo a list of found posts. Inside this loop the markers are set via
echo do_shortcode('[wpv-map-marker map_id="my-map" marker_icon="' . $icon . '" marker_id="marker-' . $post->ID . '" marker_title="' . esc_attr(str_replace(['[', ']'], [''], $post->post_title)) . '" address="' . esc_attr($address) . '"]' . $info_window . '[/wpv-map-marker]');
(the
is a compination of three custom fields street, zip code and city)
In my js i have a jquery function wich filters the loop against the inputs. The JS toggle a active class to hide / show a container if a searchword found or a term is defined.
The map with clustering is working great. The search, filter etc. in my loop via js works great too.
First: Now i want to filter also the map. With
WPViews.view_addon_maps.reload_map('my-map');
i can reload the map. But how can hide / show the marker in that map depending on the loop?
My Idea is to check wich divs are visible in the loop list, get the id from a dataset, look in the markers for this id and filter the markers. Or is there a better way?
Second: i want to include a distance filter via
[wpv-control-distance ... compare_field="..."]
. But what is the compare_field value? Can i set the custom fields like
[wpv-control-distance ... compare_field="[types field='street'][/types],[types field='zip'][/types] [types field='city'][/types]"]
?
An how do i send this distance to the js to reload the map?
My idea is to add a lat/lng attribute and compare this with the distance range.
Best