New home › Forums › Pro Add-on › General queries › ZIP-Code Search in Pro-Version
Tagged: zip code search pro addon error
- This topic has 9 replies, 4 voices, and was last updated 5 years, 2 months ago by Dylan.
-
AuthorPosts
-
January 31, 2017 at 3:04 pm #23755iamdesignMember
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.
February 1, 2017 at 8:10 am #23784DylanModeratorHi 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.
February 1, 2017 at 10:20 am #23794iamdesignMemberHi 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,
BenFebruary 2, 2017 at 7:27 am #23808DylanModeratorHi 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? π
February 2, 2017 at 10:30 am #23820iamdesignMemberHi Dylan,
i edit the file and it works like a charm!
Thank you so much for your Help.
February 3, 2017 at 7:45 am #23833DylanModeratorHi Ben,
Great to hear! Have a great day! π
November 14, 2017 at 7:42 pm #32143davegMemberThis 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.
November 16, 2017 at 3:44 pm #32190DylanModeratorHi 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! π
January 26, 2018 at 7:53 am #34077Marcus BuchwaldMemberWorks perfect! Thanks a lot, you just put a smile on my face. Looking forward to have this in Pro by default. π
January 26, 2018 at 4:19 pm #34108DylanModeratorHi Marcus,
Fantastic news, we look forward to releasing a solid fix for this in the near future!
π
-
AuthorPosts
- You must be logged in to reply to this topic.