diff --git a/modules/geolocation_googlemaps/geolocation_googlemaps.module b/modules/geolocation_googlemaps/geolocation_googlemaps.module index 8990756..27a7d9b 100644 --- a/modules/geolocation_googlemaps/geolocation_googlemaps.module +++ b/modules/geolocation_googlemaps/geolocation_googlemaps.module @@ -420,6 +420,7 @@ function geolocation_googlemaps_field_widget_form(&$form, &$form_state, $field, $element['address']['field'] = array( '#type' => 'textfield', '#maxlength' => 120, + '#default_value' => $items[$delta]['address'], ); $element['address']['geocode'] = array( '#prefix' => '', diff --git a/modules/geolocation_googlemaps/geolocation_googlemaps_widget.js b/modules/geolocation_googlemaps/geolocation_googlemaps_widget.js index e05125e..4d414bc 100644 --- a/modules/geolocation_googlemaps/geolocation_googlemaps_widget.js +++ b/modules/geolocation_googlemaps/geolocation_googlemaps_widget.js @@ -20,18 +20,22 @@ * @param op * the op that was performed */ - Drupal.geolocation.codeLatLng = function(latLng, i, op) { + Drupal.geolocation.codeLatLng = function(latLng, i, op, dontupdate) { + var update = dontupdate || 0; + // Update the lat and lng input fields $('#geolocation-lat-' + i + ' input').attr('value', latLng.lat()); $('#geolocation-lat-item-' + i + ' .geolocation-lat-item-value').html(latLng.lat()); $('#geolocation-lng-' + i + ' input').attr('value', latLng.lng()); $('#geolocation-lng-item-' + i + ' .geolocation-lat-item-value').html(latLng.lng()); - + // Update the address field if ((op == 'marker' || op == 'geocoder') && geocoder) { geocoder.geocode({'latLng': latLng}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { - $('#geolocation-address-' + i + ' input').val(results[0].formatted_address); + if (!dontupdate) { + $('#geolocation-address-' + i + ' input').val(results[0].formatted_address); + } if (op == 'geocoder') { Drupal.geolocation.setZoom(i, results[0].geometry.location_type); } @@ -45,7 +49,7 @@ }); } } - + /** * Get the location from the address field * @@ -114,7 +118,7 @@ } } - + /** * Set/Update a marker on a map * @@ -145,7 +149,7 @@ return false; // if called from -Tag } - + /** * Get the current user location if one is given * @return @@ -154,7 +158,7 @@ Drupal.geolocation.getFormattedLocation = function() { if (google.loader.ClientLocation.address.country_code == "US" && google.loader.ClientLocation.address.region) { - return google.loader.ClientLocation.address.city + ", " + return google.loader.ClientLocation.address.city + ", " + google.loader.ClientLocation.address.region.toUpperCase(); } else { @@ -162,7 +166,7 @@ + google.loader.ClientLocation.address.country_code; } } - + /** * Clear/Remove the values and the marker * @@ -177,7 +181,7 @@ $('#geolocation-address-' + i + ' input').attr('value', ''); Drupal.geolocation.markers[i].setMap(); } - + /** * Do something when no location can be found * @@ -192,7 +196,7 @@ if (supportFlag == true) { alert(Drupal.t("Geolocation service failed. We've placed you in NewYork.")); initialLocation = newyork; - } + } else { alert(Drupal.t("Your browser doesn't support geolocation. We've placed you in Siberia.")); initialLocation = siberia; @@ -289,7 +293,7 @@ if (lat && lng) { // Set initial marker - Drupal.geolocation.codeLatLng(latLng, i, 'geocoder'); + Drupal.geolocation.codeLatLng(latLng, i, 'geocoder', true); Drupal.geolocation.setMapMarker(latLng, i); }