Remove "Map,Satellite and Street view" from Map

This topic contains 15 replies, has 4 voices, and was last updated by  Kiran 3 days, 22 hours ago.

  • Author
    Posts
  • #501386

    tradingbasics
    Full Member
    Post count: 14

    Is there a way to turn off “Map,Satellite and Street view” from map view?

    I have found a thread in the forum from 2015, my guess that doesn’t apply since I’m on V2.

    #501412

    Alex Rollin
    Moderator
    Post count: 19417

    Do you mean when viewing the map on the frontend? As in, disable the map controls?

    We have a snippet for streetview. I will flag your question for the developers to see if there is also an additional parameter for the map layer control.

    https://wpgeodirectory.com/support/topic/disable-scrollwheel-on-gd_add_listing-page-map/#post-500083

    #501486

    tradingbasics
    Full Member
    Post count: 14

    Hi Alex,
    Yes, i would like to remove option to remove Map & Satellite and street view.it would be nice to have toggle switches under Geo-directory>Settings>Map Styles to turn on/off map options for site admins.
    Snippet it works for add listing page can it be modified to disable controls on map on the frontend.

    #501544

    Kor
    Moderator
    Post count: 13458

    Hi

    Thanks for your reply. Could you try using the method here https://wpgeodirectory.com/support/topic/remove-mapsatellite-from-home-page-map/#post-46387 and see if it helps?

    #501669

    tradingbasics
    Full Member
    Post count: 14

    Nope, it did not work, but I’m not sure if it is not working because of an differences between V1 and V2.

    #501682

    Alex Rollin
    Moderator
    Post count: 19417

    You added this snippet? https://gist.github.com/Stiofan/2ddaebd31553f476bc59

    I have flagged your topic for the developers to give a hint about how this works for V2

    
    /**
     * Filter the add listing map arguments.
     */
    function gd_snippet_190729_template_render_map_js_params() {
    	$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : NULL;
    	$screen_id = $screen ? $screen->id : '';
    
    	if ( ! ( $screen_id && geodir_is_gd_post_type( $screen_id ) || geodir_is_page( 'add-listing' ) ) ) {
    		return;
    	}
    
    	$params = array();
    	//$params[] = "maptype: 'ROADMAP'"; 			// Map type (ex: HYBRID, ROADMAP, SATELLITE, TERRAIN)
    	//$params[] = "zoom: 10"; 					// Default zoom (ex: 12).
    	//$params[] = "scrollwheel: false"; 			// Mouse scroll (ex: true or false).
    	//$params[] = "streetViewControl: false"; 	// Street view control (ex: true or false).
    	$params[] = "mapTypeControl: false"; 			// Map Type Control (ex: true or false).
    
    	if ( ! empty( $params ) ) {
    		echo implode( ',', $params ) . ',';
    	}
    }
    add_filter( 'geodir_template_render_map_js_params', 'gd_snippet_190729_template_render_map_js_params' , 20, 1 );
    

    Try adding that as a code snippet; let us know how it goes.

    #501814

    tradingbasics
    Full Member
    Post count: 14

    It works on Add listing page. How do I apply it to home page or all pages?
    Thanks

    #502296

    tradingbasics
    Full Member
    Post count: 14

    Hi Alex, can this snippet be applied to home page or all pages?

    #502340

    Alex Rollin
    Moderator
    Post count: 19417

    To make the changes on every page try

    
    /**
     * Filter the add listing map arguments.
     */
    function gd_snippet_19072329_template_render_map_js_params() {
    
    	$params = array();
    	//$params[] = "maptype: 'ROADMAP'"; 			// Map type (ex: HYBRID, ROADMAP, SATELLITE, TERRAIN)
    	//$params[] = "zoom: 10"; 					// Default zoom (ex: 12).
    	//$params[] = "scrollwheel: false"; 			// Mouse scroll (ex: true or false).
    	//$params[] = "streetViewControl: false"; 	// Street view control (ex: true or false).
    	$params[] = "mapTypeControl: false"; 			// Map Type Control (ex: true or false).
    
    	if ( ! empty( $params ) ) {
    		echo implode( ',', $params ) . ',';
    	}
    }
    add_filter( 'geodir_template_render_map_js_params', 'gd_snippet_19072329_template_render_map_js_params' , 20, 1 );
    

    *edit* changed function num

    #502392

    tradingbasics
    Full Member
    Post count: 14

    I tried new code in snippet, it only works on Add-Listing page, no affect on home page or any other page.

    #502394

    Alex Rollin
    Moderator
    Post count: 19417

    Edited, try it now (you wouldn’t need the first one with the second one installed.)

    #502472

    tradingbasics
    Full Member
    Post count: 14
    This reply has been marked as private.
    #502489

    Alex Rollin
    Moderator
    Post count: 19417

    Thanks, the developers will take a look.

    #502995

    Kiran
    Moderator
    Post count: 5256

    Hello tradingbasics,

    I have added following PHP snippet to disable Map Type and Street View controls from Google maps on archive & detail page maps. Snippet that you already added is works only for add listing map.

    /**
     * Remove Map Type and Street View controls from Google maps.
     */
    function gd_snippet_190814_map_params( $params, $map_args ) {
    	$map_type = $params['map_type'];
    	$map_canvas = $params['map_canvas'];
    
    	//if ( $map_canvas == 'gd_map_canvas_directory' ) {
    		$params['mapTypeControl']       = false; // Map Type control
    		$params['streetViewControl']    = false; // Street View control
    	//}
    
    	return $params;
    }
    add_filter( 'geodir_map_params', 'gd_snippet_190814_map_params', 20, 2 );

    Regards,
    Kiran

    #503058

    tradingbasics
    Full Member
    Post count: 14

    Kiran & Alex, Thank you for your support.

Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic.