Title: Problem on adding local and shortcode
Last modified: August 30, 2016

---

# Problem on adding local and shortcode

 *  Resolved [Marc](https://wordpress.org/support/users/mhollander/)
 * (@mhollander)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/problem-on-adding-local-and-shortcode/)
 * Hi,
 * I have just installed your plugin but I have two problems.
    1.  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.
    2.  When I click the shortcode button and the page is scrolled down the top of 
       the modal disappears.
 * Here are examples for both problems:
 * [Image 1](http://i.imgur.com/mQv7zoX.png)
    [Image 2](http://i.imgur.com/ekXNGIW.png)
 * Gr. Marc
 * [https://wordpress.org/plugins/where-i-was-where-i-will-be/](https://wordpress.org/plugins/where-i-was-where-i-will-be/)

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Author [Mauro Baptista](https://wordpress.org/support/users/mcnardelli/)
 * (@mcnardelli)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/problem-on-adding-local-and-shortcode/#post-6899410)
 * 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
 *  Thread Starter [Marc](https://wordpress.org/support/users/mhollander/)
 * (@mhollander)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/problem-on-adding-local-and-shortcode/#post-6899425)
 * Hi Mauro,
 * I am using a slightly modified version of twentyfiftheen.
 * See [http://marcenelsopreis.nl/](http://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.
 *  Plugin Author [Mauro Baptista](https://wordpress.org/support/users/mcnardelli/)
 * (@mcnardelli)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/problem-on-adding-local-and-shortcode/#post-6899428)
 * 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 Baptista
 *  Thread Starter [Marc](https://wordpress.org/support/users/mhollander/)
 * (@mhollander)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/problem-on-adding-local-and-shortcode/#post-6899429)
 * 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);
       }
       ```
   
 *  Thread Starter [Marc](https://wordpress.org/support/users/mhollander/)
 * (@mhollander)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/problem-on-adding-local-and-shortcode/#post-6899430)
 * 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);
       }
       ```
   
 *  Thread Starter [Marc](https://wordpress.org/support/users/mhollander/)
 * (@mhollander)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/problem-on-adding-local-and-shortcode/#post-6899431)
 * Hi,
 * I’ve changed assets/js/maps.js to the following:
    [https://gist.github.com/MGHollander/6a1bdf9046043f284037](https://gist.github.com/MGHollander/6a1bdf9046043f284037)
 * Regards,
    Marc
 *  Thread Starter [Marc](https://wordpress.org/support/users/mhollander/)
 * (@mhollander)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/problem-on-adding-local-and-shortcode/#post-6899434)
 * Sorry for spamming, but my message didn’t show. I thought it was caused by the
   code block. But suddenly they are there…
 *  Plugin Author [Mauro Baptista](https://wordpress.org/support/users/mcnardelli/)
 * (@mcnardelli)
 * [10 years, 5 months ago](https://wordpress.org/support/topic/problem-on-adding-local-and-shortcode/#post-6899469)
 * 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

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Problem on adding local and shortcode’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/where-i-was-where-i-will-be_cbdde0.
   svg)
 * [Where I Was, Where I Will Be](https://wordpress.org/plugins/where-i-was-where-i-will-be/)
 * [Support Threads](https://wordpress.org/support/plugin/where-i-was-where-i-will-be/)
 * [Active Topics](https://wordpress.org/support/plugin/where-i-was-where-i-will-be/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/where-i-was-where-i-will-be/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/where-i-was-where-i-will-be/reviews/)

 * 8 replies
 * 2 participants
 * Last reply from: [Mauro Baptista](https://wordpress.org/support/users/mcnardelli/)
 * Last activity: [10 years, 5 months ago](https://wordpress.org/support/topic/problem-on-adding-local-and-shortcode/#post-6899469)
 * Status: resolved