Remove the map from showing and calling API’s everytime you fill location

I would like to remove the map from showing and calling API’s everytime you fill location and click on search button for requests. We only need it to be shown on individual requests and not every time for everyone with and after every single search.

I’ve seen this thread, but I can’t seem to get it working for this purpose. How to Remove Map from Listing Page?

Is there any simple snippet for it? Thank you

Just to clarify, do you want to remove the map from both the search results page and the all listings page, while keeping it only on the single listing page? If that’s what you need, I can suggest a simple snippet to achieve this. Let me know!

Yes please. Needed it only for requests but now when I think about it, it would be best to restrict the map on requests result search page and also on listings results page. Need the map to show only on individual listings and individual requests after you click on it/view it.

If so, just change listing_view_page to listings_view_page in the code.

Sadly, That didn’t work. On listings I’m currently using this css:

.hp-link--hide-map.hp-link{ display: none !important; } .hp-template--listings-view-page .hp-map { display: none; } and it works great, but it’s not for requests, only for listings and also it just hides it. As you stated in your post, that’s not enough to prevent it from calling unnecessary API

It’s working fine for me.

add_filter(
	'hivepress/v1/templates/listings_view_page',
	function( $template ) {
		return hivepress()->helper->merge_trees(
			$template,
			[
				'blocks' => [
					'listing_map' => [
						'type' => 'content',
					],
				],
			]
		);
	},
	1000
);

Thanks for code, It works for me but only when searching for listings. But we also need it for requests, so it doesn’t show the map when searching requests

Hi,

Please use this PHP snippet:

add_filter(
	'hivepress/v1/templates/requests_view_page',
	function( $template ) {
		return hivepress()->helper->merge_trees(
			$template,
			[
				'blocks' => [
					'request_map' => [
						'type' => 'content',
					],
				],
			]
		);
	},
	1000
);

​I hope this is helpful to you.

Thank you @shibfox and @andrii Your two solutions work exactly as needed. Happy to be part of this community

2 Likes

Hello,

As for me, I only use the google maps api (via the geolocation extension) on the “user settings” page, just to provide “auto-suggest” feature :

But I saw it was indeed loaded on every page !

So here is a small improvement to remove it on any page but this one :

function lcl_remove_google_api_js() {
		wp_dequeue_script( 'google-maps');
		wp_deregister_script( 'google-maps');	
}
if ($_SERVER['REQUEST_URI']!=='/account/settings/'){
	add_action( 'wp_enqueue_scripts', 'lcl_remove_google_api_js', 100);
}	

Cheers !

1 Like