ZIP-Code Search in Pro-Version

New home Forums Pro Add-on General queries ZIP-Code Search in Pro-Version

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #23755
    iamdesign
    Member

    Hi there,

    i have a little issue with the store-locator.
    – zip code search (just zip code, no cityname or else) with pro-addon deactivated works fine
    – zip code search (just zip code, no cityname or else) with pro-addon activated gives me an Error in the google-console “Uncaught TypeError: Cannot read property ‘match’ of undefined” and of course no result. I need to use the autocomplete-suggestion-box (or whatever its called) to get a result.

    I run the latest versions of the pro-add-on (6.13) and free plugin (6.4.02).

    On your demo-site it works fine, but as i can see you use the 6.12 Version of the pro-addon. Can this cause the error?

    My site is currently under construction, but if you send me your current IP (https://www.whatismyip.com/) i grant you access.

    #23784
    Dylan
    Moderator

    Hi there,

    Thank you so much for getting in touch with us.

    This is due to the fact that we make use of a gecoding function (To find the coordinates of an address) which assumes the user will enter an address into the input field. Although we do have code in place to handle zip codes, this is ignored due to the function I just described.

    We are currently working on a more robust solution which will handle ZIP codes slightly better.

    However in the meantime we do have a work-around which will allow for zip codes to be entered. Are you comfortable with editing some of our code to achieve this? If so I could guide you through the process.

    So sorry for the confusion on this one.

    #23794
    iamdesign
    Member

    Hi Dylan,

    thank you for the quick reply. Yes Im comfortable with editing some code to achieve this.

    Can you tell me which files/codes i need to edit?

    Thanks,
    Ben

    #23808
    Dylan
    Moderator

    Hi Ben,

    No problem at all, please find the steps below:
    1. Please open the core.js file found in: wp-content/plugins/wp-google-maps-pro/js/core.js
    2. Find the following section of code: (Around line 275)

    if (typeof wpgmaps_localize[map_id]['other_settings']['wpgmza_store_locator_restrict'] !== "undefined" && wpgmaps_localize[map_id]['other_settings']['wpgmza_store_locator_restrict'] != "") {
                if ((wpgm_lat.match(/[a-zA-Z]/g) === null && wpgm_lng.match(/[a-zA-Z]/g) === null) && checker.length === 2 && (checker1 != NaN && (checker1 <= 90 || checker1 >= -90)) && (checker2 != NaN && (checker2 <= 90 || checker2 >= -90))) {
                    var point = new google.maps.LatLng(parseFloat(wpgm_lat),parseFloat(wpgm_lng));
                    searchLocationsNear(map_id,checkedCatValues,point,search_title);
                }
                else {
                    /* is an address, must geocode */
                    geocoder.geocode({address: address,componentRestrictions: {country: wpgmaps_localize[map_id]['other_settings']['wpgmza_store_locator_restrict']}}, function(results, status) {
                        if (status == google.maps.GeocoderStatus.OK) {
                            searchLocationsNear(map_id,checkedCatValues,results[0].geometry.location,search_title);
                        } else {
                            alert(address + ' not found');
                        }
                    });
    
                }
            } else {
    
                if ((typeof wpgm_lng !== "undefined" && wpgm_lat.match(/[a-zA-Z]/g) === null && wpgm_lng.match(/[a-zA-Z]/g) === null) && checker.length === 2 && (checker1 != NaN && (checker1 <= 90 || checker1 >= -90)) && (checker2 != NaN && (checker2 <= 90 || checker2 >= -90))) {
                    var point = new google.maps.LatLng(parseFloat(wpgm_lat),parseFloat(wpgm_lng));
                    searchLocationsNear(map_id,checkedCatValues,point,search_title);
                }
                else {
                    /* is an address, must geocode */
                geocoder.geocode({address: address}, function(results, status) {
                        if (status == google.maps.GeocoderStatus.OK) {
                            searchLocationsNear(map_id,checkedCatValues,results[0].geometry.location,search_title);
                        } else {
                            alert(address + ' not found');
                        }
                    });
    
                }
    
            } 
    

    3. Change it to the following instead:

    if (typeof wpgmaps_localize[map_id]['other_settings']['wpgmza_store_locator_restrict'] !== "undefined" && wpgmaps_localize[map_id]['other_settings']['wpgmza_store_locator_restrict'] != "") {
                    /* is an address, must geocode */
                    geocoder.geocode({address: address,componentRestrictions: {country: wpgmaps_localize[map_id]['other_settings']['wpgmza_store_locator_restrict']}}, function(results, status) {
                        if (status == google.maps.GeocoderStatus.OK) {
                            searchLocationsNear(map_id,checkedCatValues,results[0].geometry.location,search_title);
                        } else {
                            alert(address + ' not found');
                        }
                    });
            } else {
    
                    /* is an address, must geocode */
                geocoder.geocode({address: address}, function(results, status) {
                        if (status == google.maps.GeocoderStatus.OK) {
                            searchLocationsNear(map_id,checkedCatValues,results[0].geometry.location,search_title);
                        } else {
                            alert(address + ' not found');
                        }
                    });
            } 
    

    4. Save the file, and it should work as intended.

    I hope this helps? πŸ™‚

    #23820
    iamdesign
    Member

    Hi Dylan,

    i edit the file and it works like a charm!

    Thank you so much for your Help.

    #23833
    Dylan
    Moderator

    Hi Ben,

    Great to hear! Have a great day! πŸ™‚

    #32143
    daveg
    Member

    This made this product usable for me. Don’t misunderstand me to say it’s “only usable” however. It’s now exactly what I needed and a great value! Thanks SO much for this tool and this forum for diving in deeper.

    #32190
    Dylan
    Moderator

    Hi there,

    Thank you so much for sharing your thoughts, we really appreciate your time.

    I am glad to say that this will no longer be an issue in future as we are developing a major update which rebuilds this functionality into a more stable solution.

    We look forward to releasing it in the near future! πŸ™‚

    #34077
    Marcus Buchwald
    Member

    Works perfect! Thanks a lot, you just put a smile on my face. Looking forward to have this in Pro by default. πŸ™‚

    #34108
    Dylan
    Moderator

    Hi Marcus,

    Fantastic news, we look forward to releasing a solid fix for this in the near future!

    πŸ™‚

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