From cd6d72d18d10c8734becfa16c7357e887665a093 Mon Sep 17 00:00:00 2001 From: Tomasz Zdanowski Date: Thu, 4 Nov 2010 11:46:14 +0100 Subject: [PATCH 1/7] first commit --- TEST | 1 + 1 file changed, 1 insertion(+) create mode 100644 TEST diff --git a/TEST b/TEST new file mode 100644 index 0000000..3338ca9 --- /dev/null +++ b/TEST @@ -0,0 +1 @@ +THIS IS GIT TEST \ No newline at end of file From cfd6a7f4191b0b2cba48e04a58e1b237cf96a0e7 Mon Sep 17 00:00:00 2001 From: Tomasz Zdanowski Date: Thu, 4 Nov 2010 12:23:25 +0100 Subject: [PATCH 2/7] added geocode validator --- .../sfValidatorGeocodedAddress.class.php | 24 ++++++++++++++ .../sfValidatorGeocodedAddress.class.php~ | 33 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 lib/validator/sfValidatorGeocodedAddress.class.php create mode 100644 lib/validator/sfValidatorGeocodedAddress.class.php~ 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/lib/validator/sfValidatorGeocodedAddress.class.php~ b/lib/validator/sfValidatorGeocodedAddress.class.php~ new file mode 100644 index 0000000..16027eb --- /dev/null +++ b/lib/validator/sfValidatorGeocodedAddress.class.php~ @@ -0,0 +1,33 @@ +setMessage('invalid', 'WRONG_ADDRESS_%address%'); + } + + /** + * @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 From 1ab69390bcdb05259c6ef4c8caf16c49df6f35fc Mon Sep 17 00:00:00 2001 From: Tomasz Zdanowski Date: Thu, 4 Nov 2010 12:26:00 +0100 Subject: [PATCH 3/7] removed emacs backup file --- .../sfValidatorGeocodedAddress.class.php~ | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 lib/validator/sfValidatorGeocodedAddress.class.php~ diff --git a/lib/validator/sfValidatorGeocodedAddress.class.php~ b/lib/validator/sfValidatorGeocodedAddress.class.php~ deleted file mode 100644 index 16027eb..0000000 --- a/lib/validator/sfValidatorGeocodedAddress.class.php~ +++ /dev/null @@ -1,33 +0,0 @@ -setMessage('invalid', 'WRONG_ADDRESS_%address%'); - } - - /** - * @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 From db03bf98750a3bb555caff9477097f44db5f9ff7 Mon Sep 17 00:00:00 2001 From: Tomasz Zdanowski Date: Thu, 4 Nov 2010 12:27:12 +0100 Subject: [PATCH 4/7] removed test --- TEST | 1 - 1 file changed, 1 deletion(-) delete mode 100644 TEST diff --git a/TEST b/TEST deleted file mode 100644 index 3338ca9..0000000 --- a/TEST +++ /dev/null @@ -1 +0,0 @@ -THIS IS GIT TEST \ No newline at end of file From 3810ad3d2144930ff9e3d7eb5a482d795f4c97f6 Mon Sep 17 00:00:00 2001 From: Tomasz Zdanowski Date: Thu, 4 Nov 2010 14:28:39 +0100 Subject: [PATCH 5/7] fixed map object calls --- web/js/sfEasyGMapPlugin.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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) From deccd0b5c77a9a5be5240feda1d8ca9014cc10e5 Mon Sep 17 00:00:00 2001 From: Tomasz Zdanowski Date: Thu, 4 Nov 2010 14:28:48 +0100 Subject: [PATCH 6/7] fixed map object calls --- web/js/sfEasyGMapPlugin.sample.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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; } From 9790bf8a88492b32b9d9f25e1c7ddfff6991276e Mon Sep 17 00:00:00 2001 From: Tomasz Zdanowski Date: Fri, 3 Dec 2010 12:26:02 +0100 Subject: [PATCH 7/7] first import --- web/js/sspEasyGMapPlugin.js | 64 +++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 web/js/sspEasyGMapPlugin.js 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); +} +