Skip Navigation

[Resolved] default map location

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 11 replies, has 2 voices.

Last updated by niktab 1 year, 11 months ago.

Assisted by: Minesh.

Author
Posts
#2642889

Tell us what you are trying to do?
set default map location. example: results for when a location searched is not found

Is there any documentation that you are following?
wasn't able to find documentation on this.

Is there a similar example that we can see?
you can see the map on my site

What is the link to your site?
I would like to provide this information privately.

#2642973

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I would like to know are you using Toolset Blocks view or classic view to display the map? and what location you want to set as default location when no search results are found?

Could you please send me debug information that will help us to investigate your issue.
=> https://toolset.com/faq/provide-debug-information-faster-support/

#2643353

Hi Minesh,

I am using block editor and quite certain Toolset Block View is what's implemented.

Thank you!

#2643515

Minesh
Supporter

Languages: English (English )

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

Can you please try to add the following code to "Custom JS" section of your content template:

jQuery(document).ready(function($){
      
jQuery( document ).on('js_event_wpv_addon_maps_init_map_completed', function( event, event_settings ) {
 var mapid = 'map-1';   // replace with your original map ID
var map = WPViews.view_addon_maps.get_map(mapid);
  var markers = WPViews.view_addon_maps.markers[mapid];
      
    if(markers.length == 0) {
         
           mylat = 47.116386;   /// replace with your desired location lat
           mylong = -101.299591;  /// replace with your desired location long
    
             map.setZoom(3);
         map.setCenter(new google.maps.LatLng(mylat,mylong));
 }
     
      
});
      
});

Where:
- Replace mapid variable value with your original map ID
- Set mylat and mylong variable values with your desired location lat and long.

Please let me know how if you require further assistance.

#2643793

Hi Minesh,

I don't seem to get the desired results.
You still have access to the site from a previous ticket. Please feel free to take a look.

Thanks,
nikta

#2643899

Minesh
Supporter

Languages: English (English )

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

Can you please tell me what is the default location you want to set on map when there is no items found.

#2644121

Hi Minesh,

Here are the coordinates:
50.231467, -116.969406

#2644245

Minesh
Supporter

Languages: English (English )

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

Ahh - Can you please share problem URL on what view you want to set default location?

#2644351

Hi Minesh,

It is for all Single Directory Listings; here is an example: hidden link

I added the above code to the single directory listing content template.

Thank you,
nikta

#2644357

Hello again Minesh,

Is it possible to expedite and resolve this issue today, considering the weekend is coming up?

Many thanks

#2644359

Minesh
Supporter

Languages: English (English )

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

Can you please check now: hidden link

I've adjusted the custom JS code added to your content template as given under:
=> hidden link

jQuery(document).ready(function($){
function initMap() {
  var mapid = 'map-9';
  var map = WPViews.view_addon_maps.get_map(mapid);
  var markers = WPViews.view_addon_maps.markers[mapid];

if (markers === undefined){

mylat = 50.231467;   /// replace with your desired location lat
           mylong = -116.969406;  /// replace with your desired location long
     
             map.setZoom(3);
         map.setCenter(new google.maps.LatLng(mylat,mylong));

}

  } 

$( document ).on('js_event_wpv_addon_maps_init_map_completed', function( event, event_settings ) {
initMap();
} );
    
} );

Can you please confirm its working as expected now.

#2644375

Hi Minesh, it seems to be working now. Thank you.