Problem on adding local and shortcode
-
Hi,
I have just installed your plugin but I have two problems.
-
If I search for a location on adding a local I get an error.
“Geocode was not successful for the following reason: ZERO_RESULTS”.
If I close the error the maps loads the pointer, but does not fill any field. - When I click the shortcode button and the page is scrolled down the top of the modal disappears.
Here are examples for both problems:
Gr. Marc
https://www.ads-software.com/plugins/where-i-was-where-i-will-be/
-
If I search for a location on adding a local I get an error.
-
Marc,
Thanks for your message.
I’m going to check these problems as soon as possible.
Let me just know, which Theme are you using?
Mauro Baptista
Hi Mauro,
I am using a slightly modified version of twentyfiftheen.
See https://marcenelsopreis.nl/
I fixed the ZERO_RESULTS error myself in the meantime. Because your plugin is the best in it’s kind if you ask me.
Hi Marc,
Your theme shouldn′t be a problem at all.
What did you do to solve it? This way I can edit it and insert in in the new update.
Regards,
Mauro BaptistaHi Mauro,
I’ve changed assets/js/maps.js the code below.
//Show Map by Address function show_map(id, div, lat, lng) { var geocoder; var map; geocoder = new google.maps.Geocoder(); get_info = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(lat, lng); var mapOptions = { zoom: 12, center: latlng } map = new google.maps.Map(document.getElementById(div), mapOptions); jQuery('#' + div).addClass('wiw_map_local'); code_address(map, id, geocoder, get_info); } //Get info from Address function code_address(map, id, geocoder, get_info) { var address = document.getElementById('get_info' + id).value; var error_msg = wiw_vars.wiw_google_maps_error; geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location, draggable: true, }); google.maps.event.addListener(marker, 'dragend', function(event) { var latlng = new google.maps.LatLng(event.latLng.lat(), event.latLng.lng()); get_info.geocode({'latLng': latlng}, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { show_marker_info(id, results); } else { alert(error_msg + ': ' + status); } }); }); show_marker_info(id, results); } else { alert(error_msg + ': ' + status); } }); } function show_flag(div, flag, style) { jQuery('#'+div).html('<img src="'+wiw_vars.wiw_dir_images+'/flags/' + flag + '.png" class="' + style + '" onerror="imgError(this);">'); } // Show info on Form function show_marker_info(id, results) { var found_city = 0; var found_country = 0; for (var i = 0; i < results[0].address_components.length; i++) { for (var n = 0;n < results[0].address_components[i].types.length; n++) { if ((results[0].address_components[i].types[n] == "locality") && (found_city == 0)){ var city = results[0].address_components[i]; found_city = 1; } if ((results[0].address_components[i].types[n] == "country") && (found_country == 0)) { var country = results[0].address_components[i]; found_country = 1; } if ((found_city == 1) && (found_country == 1)) { break; } } } jQuery('#latitude' + id).val(results[0].geometry.location.lat()); jQuery('#longitude' + id).val(results[0].geometry.location.lng()); if (city !== undefined) jQuery('#city' + id).val(city.long_name); else jQuery('#city' + id).val(''); if (country !== undefined) { jQuery('#country' + id).val(country.long_name); jQuery('#flag' + id).val(country.short_name.toLowerCase()); show_flag('show_flag' + id, country.short_name.toLowerCase(), 'flag_preview'); } else { jQuery('#country' + id).val(''); jQuery('#flag' + id).val(''); } } //Auto Complete function auto_complete(input_id, lat, lng) { var complete; var bounds = new google.maps.LatLngBounds(new google.maps.LatLng(lat, lng),new google.maps.LatLng(lat, lng)); complete = new google.maps.places.Autocomplete((document.getElementById(input_id)),{ types: ['geocode'] }); complete.setBounds(bounds); }
Hi Mauro,
I’ve changed assets/js/maps.js the code below.
//Show Map by Address function show_map(id, div, lat, lng) { var geocoder; var map; geocoder = new google.maps.Geocoder(); get_info = new google.maps.Geocoder(); var latlng = new google.maps.LatLng(lat, lng); var mapOptions = { zoom: 12, center: latlng } map = new google.maps.Map(document.getElementById(div), mapOptions); jQuery('#' + div).addClass('wiw_map_local'); code_address(map, id, geocoder, get_info); } //Get info from Address function code_address(map, id, geocoder, get_info) { var address = document.getElementById('get_info' + id).value; var error_msg = wiw_vars.wiw_google_maps_error; geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); var marker = new google.maps.Marker({ map: map, position: results[0].geometry.location, draggable: true, }); google.maps.event.addListener(marker, 'dragend', function(event) { var latlng = new google.maps.LatLng(event.latLng.lat(), event.latLng.lng()); get_info.geocode({'latLng': latlng}, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { show_marker_info(id, results); } else { alert(error_msg + ': ' + status); } }); }); show_marker_info(id, results); } else { alert(error_msg + ': ' + status); } }); } function show_flag(div, flag, style) { jQuery('#'+div).html('<img src="'+wiw_vars.wiw_dir_images+'/flags/' + flag + '.png" class="' + style + '" onerror="imgError(this);">'); } // Show info on Form function show_marker_info(id, results) { var found_city = 0; var found_country = 0; for (var i = 0; i < results[0].address_components.length; i++) { for (var n = 0;n < results[0].address_components[i].types.length; n++) { if ((results[0].address_components[i].types[n] == "locality") && (found_city == 0)){ var city = results[0].address_components[i]; found_city = 1; } if ((results[0].address_components[i].types[n] == "country") && (found_country == 0)) { var country = results[0].address_components[i]; found_country = 1; } if ((found_city == 1) && (found_country == 1)) { break; } } } jQuery('#latitude' + id).val(results[0].geometry.location.lat()); jQuery('#longitude' + id).val(results[0].geometry.location.lng()); if (city !== undefined) jQuery('#city' + id).val(city.long_name); else jQuery('#city' + id).val(''); if (country !== undefined) { jQuery('#country' + id).val(country.long_name); jQuery('#flag' + id).val(country.short_name.toLowerCase()); show_flag('show_flag' + id, country.short_name.toLowerCase(), 'flag_preview'); } else { jQuery('#country' + id).val(''); jQuery('#flag' + id).val(''); } } //Auto Complete function auto_complete(input_id, lat, lng) { var complete; var bounds = new google.maps.LatLngBounds(new google.maps.LatLng(lat, lng),new google.maps.LatLng(lat, lng)); complete = new google.maps.places.Autocomplete((document.getElementById(input_id)),{ types: ['geocode'] }); complete.setBounds(bounds); }
Hi,
I’ve changed assets/js/maps.js to the following:
https://gist.github.com/MGHollander/6a1bdf9046043f284037Regards,
MarcSorry for spamming, but my message didn’t show. I thought it was caused by the code block. But suddenly they are there…
Nice!
I’m going to have a look on your code, and update the plugin!
Thanks!
(I’m going to mark it as solved, if you have any other problem, just open another topic!)
Regards,
Mauro Baptista
- The topic ‘Problem on adding local and shortcode’ is closed to new replies.