From: Stéphane Jacob Date: Wed, 1 Jun 2011 12:40:34 +0000 (+0200) Subject: Updates map on address edition. X-Git-Tag: xorg/1.1.2~62^2~1 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=b1f39e8bbf799e6329076e116eab22cde1b59c03;p=platal.git Updates map on address edition. Signed-off-by: Stéphane Jacob --- diff --git a/classes/gmapsgeocoder.php b/classes/gmapsgeocoder.php index 5321c72..2e44a01 100644 --- a/classes/gmapsgeocoder.php +++ b/classes/gmapsgeocoder.php @@ -30,6 +30,19 @@ class GMapsGeocoder extends Geocoder { // Maximum number of Geocoding calls to the Google Maps API. const MAX_GMAPS_RPC_CALLS = 5; + static public function buildStaticMapURL($latitude, $longitude, $color, $separator = '&') + { + $parameters = array( + 'size' => '300x100', + 'markers' => 'color:' . $color . '|' . $latitude . ',' . $longitude, + 'zoom' => '12', + 'sensor' => 'false' + ); + global $globals; + + return Platal::globals()->maps->static_map . '?' . http_build_query($parameters, '', $separator); + } + public function getGeocodedAddress(Address $address, $defaultLanguage = null, $forceLanguage = false) { $this->prepareAddress($address); $textAddress = $this->getTextToGeocode($address->text); diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js index 3a10c17..beb65ee 100644 --- a/htdocs/javascript/profile.js +++ b/htdocs/javascript/profile.js @@ -328,9 +328,13 @@ function addAddress() checkCurrentAddress()); } -function addressChanged(prefid) +function addressChanged(prefid, color) { + var text = $('#' + prefid + '_cont').find("[name*='[text]']").val(); $('#' + prefid + '_cont').find('[name*=changed]').val("1"); + $.xpost('map_url/', { text:text, color:color }, function(data) { + $('.static_map_url').find('img').attr('src', data); + }); } function deleteGeocoding(prefid, hrpid) diff --git a/modules/geoloc.php b/modules/geoloc.php index c0402bf..762e1ac 100644 --- a/modules/geoloc.php +++ b/modules/geoloc.php @@ -24,7 +24,8 @@ class GeolocModule extends PLModule function handlers() { return array( - 'map' => $this->make_hook('map', AUTH_COOKIE) + 'map' => $this->make_hook('map', AUTH_COOKIE), + 'map_url' => $this->make_hook('map_url', AUTH_COOKIE) ); } @@ -68,6 +69,20 @@ class GeolocModule extends PLModule self::prepare_map($page); } } + + function handler_map_url($page) + { + pl_content_headers('text/plain'); + + if (Post::has('text')) { + $address = new Address(array('text' => Post::t('text'))); + $gmapsGeocoder = new GMapsGeocoder(); + $gmapsGeocoder->getGeocodedAddress($address); + echo GMapsGeocoder::buildStaticMapURL($address->latitude, $address->longitude, Post::t('color')); + } + + exit(); + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: diff --git a/plugins/insert.getStaticMapURL.php b/plugins/insert.getStaticMapURL.php new file mode 100644 index 0000000..8f64637 --- /dev/null +++ b/plugins/insert.getStaticMapURL.php @@ -0,0 +1,28 @@ + diff --git a/templates/geoloc/form.address.tpl b/templates/geoloc/form.address.tpl index b05ac49..8bde680 100644 --- a/templates/geoloc/form.address.tpl +++ b/templates/geoloc/form.address.tpl @@ -26,7 +26,7 @@ {/if} - + @@ -52,9 +52,8 @@ {/if} - {if t($address.latitude)} - Position de l'adresse +
+ promoColor()}" alt="Position de l'adresse" /> {if t($geocoding_removal)}
@@ -65,7 +64,7 @@ {/if} {/if} - {/if} +
{if t($validation)}