Fixes the opening of the comments panel in validations (Closes #1571)
[platal.git] / classes / gmapsgeocoder.php
index 9378c1b..302080f 100644 (file)
@@ -30,6 +30,22 @@ 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 = '&')
+    {
+        if (!$latitude || !$longitude) {
+            return null;
+        }
+
+        $parameters = array(
+            'size'    => '300x100',
+            'markers' => 'color:' . $color . '|' . $latitude . ',' . $longitude,
+            'zoom'    => '12',
+            'sensor'  => 'false'
+        );
+
+        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);
@@ -38,6 +54,7 @@ class GMapsGeocoder extends Geocoder {
         }
 
         // Try to geocode the full address.
+        $address->geocoding_calls = 1;
         if (($geocodedData = $this->getPlacemarkForAddress($textAddress, $defaultLanguage))) {
             $this->getUpdatedAddress($address, $geocodedData, null, $forceLanguage);
             return;
@@ -52,6 +69,7 @@ class GMapsGeocoder extends Geocoder {
         for ($i = max(1, $linesCount - self::MAX_GMAPS_RPC_CALLS + 1); $i < $linesCount; ++$i) {
             $extraLines = implode("\n", array_slice($addressLines, 0, $i));
             $toGeocode  = implode("\n", array_slice($addressLines, $i));
+            ++$address->geocoding_calls;
             if (($geocodedData = $this->getPlacemarkForAddress($toGeocode, $defaultLanguage))) {
                 $this->getUpdatedAddress($address, $geocodedData, $extraLines, $forceLanguage);
                 return;