Can I set a minZoom on the map

This topic contains 6 replies, has 3 voices, and was last updated by  Stiofan O’Connor 8 years, 5 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #297350

    Paul
    Buyer
    Post count: 8

    Is there a way to set the minZoom level for the main map.
    My customers are only located in one country so its seems silly if the can zoom out to the world.
    Dont mind coding.

    For example in Google maps you can set
    var mapOptions = {
    minZoom: 7,
    maxZoom: 11,
    };

    Thanks.

    #297563

    Paolo
    Site Admin
    Post count: 31211

    Hi,

    I’ve assigned this to the developers. They’ll let you know asap.

    Thanks

    #297570

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Paul,

    There is a hook for that but you must know the name of the map $map_canvas_name:

    apply_filters("geodir_map_options_{$map_canvas_name}", $geodir_map_options);

    For the homepage map it will be something like geodir_map_v3_home_map_x
    You can view the source code of the map and u will see it mentioned several times.

    Once you have the name say “geodir_map_v3_home_map_1” you would add this to your child theme functions.php:

    
    
    add_filter("geodir_map_options_geodir_map_v3_home_map_1","_my_map_minzoom",10,1);
    function _my_map_minzoom($geodir_map_options){
        $geodir_map_options['minZoom'] = 7;
        return $geodir_map_options;
    }

    Thanks,

    Stiofan

    #298556

    Paul
    Buyer
    Post count: 8

    Thanks Stiofan, Tried the above and the page source seems to indicate that it has picked it up

    
    
    <script type="text/javascript">
    /* <![CDATA[ */
    var geodir_map_v3_home_map_1 = {"width":"100%","height":"425px","child_collapse":"0","sticky":"","enable_map_resize_button":"1","enable_cat_filters":"1","enable_text_search":"1","enable_post_type_filters":"1","enable_location_filters":"1","enable_jason_on_load":"","enable_map_direction":"","enable_marker_cluster":"","ajax_url":"http://127.0.0.1:88/wordpress/wp-admin/admin-ajax.php?action=geodir_ajax_action","map_canvas_name":"geodir_map_v3_home_map_1","inputText":"Title or Keyword","latitude":"53.4239331","longitude":"-7.940689799999973","zoom":"13","scrollwheel":"0","streetViewControl":"1","maptype":"ROADMAP","showPreview":"0","maxZoom":"9","autozoom":"1","bubble_size":"small","token":"68f48005e256696074e1da9bf9f67f06","navigationControlOptions":{"position":"TOP_LEFT","style":"ZOOM_PAN"},"map_class_name":"geodir-map-home-page","is_geodir_home_map_widget":"1","minZoom":"5"};
    var geodir_map_v3_home_map_1_jason_args = {"geodir_map_v3_home_map_1_jason":"[{"totalcount":"0"}]"};
    /* ]]> */
    </script>

    But when I click on the “+/-” map zoom icon, it still allows me to go passed both minZoom and maxZoom settings per code. Is there something else I’m missing?

    I using the geodir default “GD Home Page” to test this on.

    Regards
    Paul.

    #298573

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Paul,

    You are right, somehow that functionality was removed, i have added it back and it will be in the next release, if you need it sooner you can download the dev version here: https://github.com/GeoDirectory/geodirectory

    Thanks,

    Stiofan

    #299502

    Paul
    Buyer
    Post count: 8

    Thank you Stiofan. At least now I know I’m not going mad!.

    Cheers for the fix.
    Case closed.

    #299505

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Great 🙂

Viewing 7 posts - 1 through 7 (of 7 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount