Radius and zoom

New home Forums Pro Add-on Radius and zoom

Tagged: ,

Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
  • #22243

    I have a map with the shopping finder enabled;

    All shops/locations are in the same town so the map -only- shows the part with this town;

    When people search with their postal code and have for example 10 miles as default radius selected, the search results makes the map to zoom out (to roughly the 10 miles) so that a big area around the town is shown, but no markers because they are only in the town itself;

    This leads to the impression that there is a big area but the shops aren’t showing (note: an unsuspecting visitor doesn’t know that all shops are just in one town);

    Is there a way to either keep the zoom in factor of the map at all times or to not have the miles radius dropdown selector showing and/or perhaps have a possibility to change the default selected number of miles and even better: to be able to set the selectable radius amounts yourself?


    Hi there,

    Thank you so much for taking a moment to get in touch with us.

    If I am understanding your question correctly, perhaps the best solution would be to show all markers (regardless of if they are within radius) as this will show the user where the markers are located?

    If this is a possible solution, the following thread may help with applying the required changes: https://www.wpgmaps.com/forums/topic/store-locator-map-markers-not-showing-under-25-miles/

    I would be more than happy to assist with the changes if you would prefer?


    Hi Dylan,

    Well in fact all markers are already showing on the map with the set zoom ration of the map.
    Nevertheless a visitor may want to use the radius search option to find the nearest shop to his/her home.
    But the when having the search option active, the default radius amounts are way to high and cannot be modified, neither can the pre-selected amount be changed to another.
    Imo a real flaw in this great plugin.

    Kind regards,


    Hi Pieter,

    Thank you so much for clarifying what you are trying to achieve.

    Although you are correct in saying that this cannot be set within the settings area, it can be adjusted by making some minor changes to the plugin code if you are open to this?

    If so, I would be happy to guide you through the process?

    We will be adding this as an option in the future though. 🙂


    Would be great to have this as a future feature!

    If you have code change instructions, I can carry them out.


    Hi Pieter,

    Please find the instructions below:
    1. You will need to edit the Pro add-on’s PHP file in order to apply these changes. This can be via FTP using a code editor of your choice, or alternatively via the WordPress editor as seen below:
    – a: Hover over the button labelled ‘Plugins’.
    – b: Click on the button labelled ‘Editor’ (Found in the sub-menu).
    – c: From the dropdown menu on the right-hand side select WP Google Maps Pro Add-on.
    – d: Click the ‘Select’ button next to the dropdown to open the default file.
    – e: This should open wp-google-maps-pro.php for editing.
    2. With the main PHP file open (wp-content/plugins/wp-google-maps-pro/wp-google-maps-pro.php) please find the following segment of code:

    $ret_msg .= "<option class=\"wpgmza_sl_select_option\" value=\"1\">".__("1mi","wp-google-maps")."</option>";
    $ret_msg .= "<option class=\"wpgmza_sl_select_option\" value=\"5\">".__("5mi","wp-google-maps")."</option>";
    $ret_msg .= "<option class=\"wpgmza_sl_select_option\" value=\"10\" selected>".__("10mi","wp-google-maps")."</option>";
    $ret_msg .= "<option class=\"wpgmza_sl_select_option\" value=\"25\">".__("25mi","wp-google-maps")."</option>";
    $ret_msg .= "<option class=\"wpgmza_sl_select_option\" value=\"50\">".__("50mi","wp-google-maps")."</option>";
    $ret_msg .= "<option class=\"wpgmza_sl_select_option\" value=\"75\">".__("75mi","wp-google-maps")."</option>";
    $ret_msg .= "<option class=\"wpgmza_sl_select_option\" value=\"100\">".__("100mi","wp-google-maps")."</option>";
    $ret_msg .= "<option class=\"wpgmza_sl_select_option\" value=\"150\">".__("150mi","wp-google-maps")."</option>";
    $ret_msg .= "<option class=\"wpgmza_sl_select_option\" value=\"200\">".__("200mi","wp-google-maps")."</option>";
    $ret_msg .= "<option class=\"wpgmza_sl_select_option\" value=\"300\">".__("300mi","wp-google-maps")."</option>";

    3. The segment of code seen above can be altered to your preference. For this example we will change the 5mi option to a 7mi option instead by changing the following line:

    $ret_msg .= "<option class=\"wpgmza_sl_select_option\" value=\"5\">".__("5mi","wp-google-maps")."</option>";

    4. To something like this instead:

    $ret_msg .= "<option class=\"wpgmza_sl_select_option\" value=\"7\">".__("7mi","wp-google-maps")."</option>";

    Notice how the value and the string were changed to reflect our new distance.

    5. Once you have changed each line to your preference, you can save the file and it should all work.

    I hope this helps? 🙂


    Thanks for the instruction, one more question, there are basically two instances of the code, the part you mention with if before it and the same code after that with else before it.
    Do I need to change both instances then?

    [code]if (isset($map_other_settings[‘store_locator_distance’]) && $map_other_settings[‘store_locator_distance’] == 1) {
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”1\”>”.__(“1mi”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”5\”>”.__(“5mi”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”10\” selected>”.__(“10mi”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”25\”>”.__(“25mi”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”50\”>”.__(“50mi”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”75\”>”.__(“75mi”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”100\”>”.__(“100mi”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”150\”>”.__(“150mi”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”200\”>”.__(“200mi”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”300\”>”.__(“300mi”,”wp-google-maps”).”</option>”;
    } else {
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”1\”>”.__(“1km”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”5\”>”.__(“5km”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”10\” selected>”.__(“10km”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”25\”>”.__(“25km”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”50\”>”.__(“50km”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”75\”>”.__(“75km”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”100\”>”.__(“100km”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”150\”>”.__(“150km”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”200\”>”.__(“200km”,”wp-google-maps”).”</option>”;
    $ret_msg .= ” <option class=\”wpgmza_sl_select_option\” value=\”300\”>”.__(“300km”,”wp-google-maps”).”</option>”;


    Oh I now see the ‘else’ reason: to show the distance in km when miles is not set as distance. 🙂

    I have managed to change the distances.
    You have no nifty code modification to stop the zoom in which now happens?
    Or to limit the zoom in level after you have set a distance and clicked search?


    Hi Pieter,

    Yes, that is correct, only the first part of the if statement is relevant as you are using miles instead of kilometers.

    You can edit the zoom levels within the core.js file (wp-google-maps-pro/js/core.js) by changing the following segment of code to your preference:

    if (radius === "1") { zoomie = 14; }
    else if (radius === "5") { zoomie = 12; }
    else if (radius === "10") { zoomie = 11; }
    else if (radius === "25") { zoomie = 9; }
    else if (radius === "50") { zoomie = 8; }
    else if (radius === "75") { zoomie = 8; }
    else if (radius === "100") { zoomie = 7; }
    else if (radius === "150") { zoomie = 7; }
    else if (radius === "200") { zoomie = 6; }
    else if (radius === "300") { zoomie = 6; }
    else { zoomie = 14; }   

    Where the zoomie variable will determine the zoom level of the map.

    This is again wrapped in a check which determines the difference between mi and km.

    I hope this helps?


    Hi Dylan, that did all I wanted to achieve! 🙂
    Thank you so much for helping out here!

    One final question, these modification will be overwritten when a new update is done, correct?
    Or is there also a way to keep these modifications the way one can do with a child theme?


    Hi Pieter,

    My pleasure! Always happy to help! 🙂

    Unfortunately there is no way of moving this to a child theme, as it integrates with core functionality of the plugin.

    We are planning on adding more WordPress hooks and filters to work around this in the future. However as mentioned earlier we will most likely allow for both these changes to be made via settings in the future.

    So sorry about that, for the time being you will need to re-apply the fix upon update.


    No worries, happy anyways 🙂


    Hi Pieter,

    So glad to hear that! 🙂

    Have a great day, and let me know if you need anything else!


    Hi Dylan,

    although off topic in this thread, I would like to ask you if you could help me with some other issue as well, please see: https://www.wpgmaps.com/forums/topic/translation-of-get-directions-not-complete/
    This is the last thing that is bugging me for some time now.


    Hi Pieter,

    Of course, I would be happy to help.

    I will respond on that thread so that anyone else having the same issue can follow along. 🙂

    However the following thread should guide your through the process:


Viewing 15 posts - 1 through 15 (of 21 total)
  • You must be logged in to reply to this topic.