Skip Navigation

[Resolved] Split: How to show map results, distanced by miles with exceptions – set default location when no result found with map

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 6 replies, has 2 voices.

Last updated by simonC-7 1 year, 8 months ago.

Assisted by: Minesh.

Author
Posts
#2583039

Hi, I am sorry to re-open this ticket but I am finding 2 problems:

2 - When there are no results, eg:
Show results within 5 miles of Hull UK
- Personal Policy - selected
- Health insurance - checked
- National Broker - NOT CHECKED

The map is no longer defaulting to an empty UK.

#2583063

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I would like to just confirm that when there is no result found you want to set the default user location to UK - right?

#2583653

Thank you, that is correct, AS WELL AS when the page first loads too.

#2583915

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've added the following code to your block view's "Loop Output" section's "Loop Template" box where we add No items found message.

[wpv-conditional if="( '[wpv-attribute name='wpv_view_count']' eq '' )"]

[wpv-map-marker map_id='map-4' marker_id='marker-999' marker_title='United Kingdom' address='United Kingdom']
United Kingdom
[/wpv-map-marker]

[/wpv-conditional]

I can see now marker is added as default United Kingdom.

#2584035
Screenshot 2023-03-31 at 11.29.05.png

Hi, there should be no marker. Just a map of the UK, as on the current production site.

hidden link

#2584057

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

To center the map without pin I've added the following custom JS code to your view's "Custom CSS and JS" section's custom JS editor:

jQuery(document).ready(function($){
   
jQuery( document ).on('js_event_wpv_addon_maps_init_map_completed', function( event, event_settings ) {
 var mapid = 'map-4';
  var map = WPViews.view_addon_maps.get_map(mapid);
  var markers = WPViews.view_addon_maps.markers[mapid];
   
 
  if (typeof markers == "undefined") {
    
   
  mylat = 51.509865;
  mylong = -0.118092;
 
  map.setZoom(3);
  map.setCenter(new google.maps.LatLng(mylat,mylong));
   
  
   
  }
   
});
   
});

I can see now its displaying the correct map. Can you please confirm.

#2584067

Thank you, I adjusted the long & lat and zoom in your code to get the desired position. My issue is resolved now. Thanks again.