Add '15 miles' to store locator radius drop-down?

New home Forums Pro Add-on General queries Add '15 miles' to store locator radius drop-down?

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #24749
    adambradford
    Member

    Hi,

    I am using the Store Locator above a map and it works very well.

    The ‘Radius’ drop-down starts at 10 miles and then goes up to 25 miles, 50 miles etc. The site owner is asking me if it is possible to add an additional figure of 15 miles in there?

    Thanks.

    Adam.

    #24752
    adambradford
    Member

    Hi Nick,

    Thanks for your reply. I’m perfectly happy to make changes to the code my end, but since I’ve already made some changes (as seen in this thread: https://www.wpgmaps.com/forums/topic/change-map-marker-list-to-direct-links), I’m a little worried that if I keep making changes, it will be very difficult if you guys update the plugin at some point and I then need to re-enter all my changes if I want to use the new version!

    Please could you publish the required code changes, and I’ll then decide whether to use them? If not then at least it may help someone else looking here with the same requirement!

    Thanks,

    Adam.

    #24806
    Dylan
    Moderator

    Hi Adam,

    Thank you so much for your time on this one.

    This can be achieved by finding the following segment of code in the wp-google-maps-pro/wp-google-maps-pro.php file:

    
     $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>";

    And simply adding another ‘option’ field as seen here:

     $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=\"15\" selected>".__("15mi","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>";

    I hope this helps? 🙂

    #25020
    adambradford
    Member

    Hi Dylan,

    Since this required only a small addition to the code, I decided to implement it, and it worked a treat. Many thanks.

    Adam.

    #25027
    Dylan
    Moderator

    Hi Adam,

    My pleasure, glad to hear it helped!

    Please shout if you need any further assistance in future.

    Have a great week! 🙂

    #25034
    adambradford
    Member

    Hi Dylan,

    Unfortunately I spoke too soon, the page in question is exhibiting strange behaviour.

    Please could you have a look?

    https://www.mamababybliss.com/find-a-class-or-therapist-near-you

    Thanks,

    Adam.

    #25040
    Dylan
    Moderator

    Hi Adam,

    So sorry for the issues you are having.

    I had a look at your map, however it appears to be working as intended.

    Perhaps I am overlooking something on my side?

    #25041
    adambradford
    Member

    Hi Dylan,

    If you try to search for a place name, for example “Mapperley” on a 10 mile radius, and note the number of pins in the circle.

    Then try the same search with a 15 mile radius, and you’ll see firstly that there is no circle, and secondly that nearly all the pins are missing.

    Thanks,

    Adam.

    #25044
    Nick Duncan
    Keymaster

    Hi Adam
    Sorry about that. There is one more thing to change!
    Please open wp-google-maps-pro/js/core.js and search for this function:

    function searchLocationsNear(mapid,category,center_searched,search_title) {
        clearLocations();
        var distance_type = document.getElementById("wpgmza_distance_type_"+mapid).value;
        var radius = document.getElementById('radiusSelect_'+mapid).value;
        if (parseInt(category) === 0) { category = 'all'; }
        if (category === "0") { category = 'all'; }
        if (category === "Not found") { category = 'all'; }
        if (category === null) { category = 'all'; }
        if (category.length < 1) { category = 'all'; }
    
        if (distance_type === "1") {
            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; }
        } else {
            if (radius === "1") { zoomie = 14; }
            else if (radius === "5") { zoomie = 12; }
            else if (radius === "10") { zoomie = 11; }
            else if (radius === "25") { zoomie = 10; }
            else if (radius === "50") { zoomie = 9; }
            else if (radius === "75") { zoomie = 9; }
            else if (radius === "100") { zoomie = 8; }
            else if (radius === "150") { zoomie = 8; }
            else if (radius === "200") { zoomie = 7; }
            else if (radius === "300") { zoomie = 7; }
            else { zoomie = 14; }
        }
        

    Please change that too:

    function searchLocationsNear(mapid,category,center_searched,search_title) {
        clearLocations();
        var distance_type = document.getElementById("wpgmza_distance_type_"+mapid).value;
        var radius = document.getElementById('radiusSelect_'+mapid).value;
        if (parseInt(category) === 0) { category = 'all'; }
        if (category === "0") { category = 'all'; }
        if (category === "Not found") { category = 'all'; }
        if (category === null) { category = 'all'; }
        if (category.length < 1) { category = 'all'; }
    
        if (distance_type === "1") {
            if (radius === "1") { zoomie = 14; }
            else if (radius === "5") { zoomie = 12; }
            else if (radius === "10") { zoomie = 11; }
            else if (radius === "15") { 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; }
        } else {
            if (radius === "1") { zoomie = 14; }
            else if (radius === "5") { zoomie = 12; }
            else if (radius === "10") { zoomie = 11; }
            else if (radius === "15") { zoomie = 11; }
            else if (radius === "25") { zoomie = 10; }
            else if (radius === "50") { zoomie = 9; }
            else if (radius === "75") { zoomie = 9; }
            else if (radius === "100") { zoomie = 8; }
            else if (radius === "150") { zoomie = 8; }
            else if (radius === "200") { zoomie = 7; }
            else if (radius === "300") { zoomie = 7; }
            else { zoomie = 14; }
        }
        
    • This reply was modified 6 years ago by Nick Duncan.
    • This reply was modified 6 years ago by Nick Duncan.
    #25048
    adambradford
    Member

    Thanks Nick, that works perfectly.

    Adam.

    #25052
    adambradford
    Member

    Hi,

    Sorry to keep bothering you about this, but I just noticed an issue. Under Advanced Settings I use the first option for Infowindow Style (the default, I think). This displays perfectly when a pin is clicked without first using the locator.

    However, if I enter a search term into the box and search within any radius, clicking a pin means that the Infowindow shows the photo at the top (instead of to the right where I wanted it) and in some cases this obscures the text.

    Is it possible that the modifications have broken something?

    Adam.

    #25057
    Nick Duncan
    Keymaster

    Hi Adam

    This is a confirmed bug, sorry about that. To fix this (in the meantime, until we release the new version), please change the following in the core.js (pro):

    if (wpgmaps_localize_global_settings['wpgmza_settings_image_width'] === "" || 'undefined' === typeof wpgmaps_localize_global_settings['wpgmza_settings_image_width']) { wpgmaps_localize_global_settings['wpgmza_settings_image_width'] = 'auto'; } else { wpgmaps_localize_global_settings['wpgmza_settings_image_width'] = wpgmaps_localize_global_settings['wpgmza_settings_image_width']+'px'; }
                if (wpgmaps_localize_global_settings['wpgmza_settings_image_height'] === "" || 'undefined' === typeof wpgmaps_localize_global_settings['wpgmza_settings_image_height']) { wpgmaps_localize_global_settings['wpgmza_settings_image_height'] = 'auto'; } else { wpgmaps_localize_global_settings['wpgmza_settings_image_height'] = wpgmaps_localize_global_settings['wpgmza_settings_image_height']+'px'; }

    To this instead:

    
    if (wpgmaps_localize_global_settings['wpgmza_settings_image_width'] === "" || 'undefined' === typeof wpgmaps_localize_global_settings['wpgmza_settings_image_width']) { 
                    wpgmaps_localize_global_settings['wpgmza_settings_image_width'] = 'auto'; 
                } else { 
                    if(wpgmaps_localize_global_settings['wpgmza_settings_image_width'].indexOf('px') === -1){
                        wpgmaps_localize_global_settings['wpgmza_settings_image_width'] = wpgmaps_localize_global_settings['wpgmza_settings_image_width'] + "px"; 
                    }
                }
    
                if (wpgmaps_localize_global_settings['wpgmza_settings_image_height'] === "" || 'undefined' === typeof wpgmaps_localize_global_settings['wpgmza_settings_image_height']) { 
                    wpgmaps_localize_global_settings['wpgmza_settings_image_height'] = 'auto'; 
                } else { 
                    if(wpgmaps_localize_global_settings['wpgmza_settings_image_height'].indexOf('px') === -1){
                        wpgmaps_localize_global_settings['wpgmza_settings_image_height'] = wpgmaps_localize_global_settings['wpgmza_settings_image_height'] + 'px'; 
                    }
                }
    
    • This reply was modified 6 years ago by Nick Duncan.
    • This reply was modified 6 years ago by Nick Duncan.
    #27273
    jwrightspplus
    Member

    Question…. would not all the recommended changed mentioned here be wiped out when the Pro Plugin gets updated?

    #27292
    Dylan
    Moderator

    Hi there,

    Yes that is correct, unfortunately these changes will be undone upon updating the plugin.

    We will be adding options in the future to customize the radius options permanently from within the settings.

    I hope this helps?

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