diff --git a/lib/validator/sfValidatorGeocodedAddress.class.php b/lib/validator/sfValidatorGeocodedAddress.class.php
new file mode 100644
index 0000000..5d0b7e1
--- /dev/null
+++ b/lib/validator/sfValidatorGeocodedAddress.class.php
@@ -0,0 +1,24 @@
+setMessage('invalid', 'Address "%address%" could not be geolocated with google maps');
+ }
+
+ /**
+ * @see sfValidatorBase
+ */
+ protected function doClean($value)
+ {
+ $map = new GMap();
+ $address = new GMapGeocodedAddress($value);
+ if($address->geocode($map->getGMapClient()))
+ {
+ return $value;
+ }
+
+ throw new sfValidatorError($this, 'invalid',array('address'=>$value));
+ }
+}
\ No newline at end of file
diff --git a/web/js/sfEasyGMapPlugin.js b/web/js/sfEasyGMapPlugin.js
index 6db786c..ba961b0 100644
--- a/web/js/sfEasyGMapPlugin.js
+++ b/web/js/sfEasyGMapPlugin.js
@@ -50,9 +50,9 @@ var set_location = function(response, status)
marker.gps_precision = zoom;
//console.log('position settée ' + marker.google_position);
- marker.set_position(point);
- map.set_zoom(zoom);
- map.set_center(point);
+ marker.setPosition(point);
+ map.setZoom(zoom);
+ map.setCenter(point);
}
var geocode_and_show = function (address)
diff --git a/web/js/sfEasyGMapPlugin.sample.js b/web/js/sfEasyGMapPlugin.sample.js
index e47bbcf..a1f65af 100644
--- a/web/js/sfEasyGMapPlugin.sample.js
+++ b/web/js/sfEasyGMapPlugin.sample.js
@@ -2,8 +2,8 @@
var moveToMarker = function ()
{
var darwin = new google.maps.LatLng(-12.461334, 130.841904);
- map.set_zoom(13);
- map.set_center(darwin);
+ map.setZoom(13);
+ map.setCenter(darwin);
gmapSample_AddConsoleLine("You just click on Darwin's marker !");
}
@@ -34,6 +34,8 @@ var gmapSample_AddConsoleLine = function (content)
var line = '
' + time + ' >' + content + '
';
console.innerHTML = inner_console + line;
+
+
return false;
}
diff --git a/web/js/sspEasyGMapPlugin.js b/web/js/sspEasyGMapPlugin.js
new file mode 100644
index 0000000..e0414aa
--- /dev/null
+++ b/web/js/sspEasyGMapPlugin.js
@@ -0,0 +1,64 @@
+var update_form_data = function()
+{
+ $('.gmap_address').val(marker.google_position);
+ $('.gmap_lng').html(this.position.lng());
+ //$('#sf_guard_user_gps_precision').val(this.gps_precision);
+ //console.log('position lue ' + marker.google_position);
+ $('.gmap_lat').html(this.position.lat());
+}
+
+var set_clicked_location = function(response, status)
+{
+ if(status != google.maps.GeocoderStatus.OK)
+ {
+ alert('Oops... adress not recognized by Google !');
+ return false;
+ }
+
+ var zoom=15;
+ //console.log(response[0].geometry);
+ //console.log(response[0].geometry.location_type);
+ switch(response[0].geometry.location_type)
+ {
+ // country level
+ case google.maps.GeocoderLocationType.APPROXIMATE:
+ zoom=9;
+ break;
+ case google.maps.GeocoderLocationType.GEOMETRIC_CENTER:
+ zoom=11;
+ break;
+ // city level
+ case google.maps.GeocoderLocationType.RANGE_INTERPOLATED:
+ zoom=13;
+ break;
+ case google.maps.GeocoderLocationType.ROOFTOP:
+ zoom=14;
+ break;
+ default:
+ zoom=14;
+ break;
+ }
+
+ point = response[0].geometry.location;
+ //console.log(point);
+
+ if (typeof marker == 'undefined')
+ {
+ marker = new google.maps.Marker({'map': map, draggable: true});
+ google.maps.event.addListener(marker, 'position_changed', update_form_data)
+ }
+ marker.google_position = response[0].formatted_address;
+ marker.gps_precision = zoom;
+
+ marker.setPosition(point);
+ marker.setVisible(true);
+ //map.setZoom(zoom);
+ //map.setCenter(point);
+}
+
+var geocode_clicked = function (event)
+{
+ var geocoder = new google.maps.Geocoder();
+ geocoder.geocode({'location': event.latLng}, set_clicked_location);
+}
+