/**
  * Construct from a GMapGeocodedAddress object
  *
  * @param string $js_name
  * @param GMapGeocodedAddress $gmap_geocoded_address
  * @return GMapMarker
  */
 public static function constructFromGMapGeocodedAddress($gmap_geocoded_address, $js_name = 'marker')
 {
     if (!$gmap_geocoded_address instanceof GMapGeocodedAddress) {
         throw new sfException('object passed to constructFromGMapGeocodedAddress is not a GMapGeocodedAddress');
     }
     return new GMapMarker($js_name, $gmap_geocoded_address->getLat(), $gmap_geocoded_address->getLng());
 }
Ejemplo n.º 2
0
  /**
   * Geocodes an address and returns additional normalized information
   * @param string $address
   * @return GMapGeocodedAddress
   * @author Fabrice Bernhard
   */
  public function geocodeXml($address)
  {
    $address = trim($address);

    $gMapGeocodedAddress = new GMapGeocodedAddress($address);
    $gMapGeocodedAddress->geocodeXml($this->getGMapClient());

    return $gMapGeocodedAddress;
  }
Ejemplo n.º 3
0
 /**
  * Multiple GMapInfoWindow sample
  *
  * @author Vincent Guillon <*****@*****.**>
  * @since 2010-03-04
  */
 public function executeSample10()
 {
     // Initialize the google map
     $gMap = new GMap();
     $markers = array(new GMapMarker(51.245475, 6.821373), new GMapMarker(46.262248, 6.115969), new GMapMarker(48.848959, 2.341577), new GMapMarker(48.718952, 2.21918), new GMapMarker(47.37642, 8.547995));
     foreach ($markers as $marker) {
         // Reverse geocoding of the center of the map
         $geocoded_addr = new GMapGeocodedAddress(null);
         $geocoded_addr->setLat($marker->getLat());
         $geocoded_addr->setLng($marker->getLng());
         $geocoded_addr->reverseGeocode($gMap->getGMapClient());
         $info_window = new GMapInfoWindow('<div>' . $geocoded_addr->getRawAddress() . '</div>');
         $marker->addHtmlInfoWindow($info_window);
         $gMap->addMarker($marker);
     }
     // Center the map on marker width 0.3 margin
     $gMap->centerAndZoomOnMarkers(0.3);
     $this->gMap = $gMap;
     $this->setTemplate('sample1');
     // END OF ACTION
     $this->message = 'Multiple info window : click marker to open info window';
     $this->action_source = $this->functionToString('executeSample10');
 }
Ejemplo n.º 4
0
  /**
   * GMapGeocodedAddress sample
   *
   * @author Vincent Guillon <*****@*****.**>
   * @since 2009-10-16 15:25:11
   */
  public function executeSample7()
  {
    // Initialize the google map
    $this->gMap = new GMap();
    $this->gMap->setWidth(512);
    $this->gMap->setHeight(400);
    $this->gMap->setZoom(16);

    $sample_address = '60 rue de Seine, 75006 Paris, France';
    
    // Create geocoded address
    $geocoded_address = new GMapGeocodedAddress($sample_address);
    $geocoded_address->geocode($this->gMap->getGMapClient());
    
    // Center the map on geocoded address
    $this->gMap->setCenter($geocoded_address->getLat(), $geocoded_address->getLng());
    
    // Add marker on geocoded address
    $this->gMap->addMarker(
      new GMapMarker($geocoded_address->getLat(), $geocoded_address->getLng())
    );

    $this->setTemplate('sample1');

    // END OF ACTION
    $this->message = 'Display a marker on geocoded address "'.$sample_address.'" and center the map.';
    $this->action_source = $this->functionToString('executeSample7');
    $this->generated_js = str_replace(' ', '&nbsp;', preg_replace('/^\n(.*)/', '$1', $this->gMap->getJavascript()));
  }
<?php

/**
 * Teste la sauvegarde d'équipes dans le backend
 * @author fabriceb
 * @since Feb 16, 2009 fabriceb
 */
include dirname(__FILE__) . '/../bootstrap/unit.php';
$t = new lime_test(15, new lime_output_color());
$t->diag('GMapGeocodedAddress Tests');
$gAddress = new GMapGeocodedAddress('60 rue de Seine, Paris');
$t->diag('->getRawAddress');
$t->is($gAddress->getRawAddress(), '60 rue de Seine, Paris', '->getRawAddress ok');
require_once dirname(__FILE__) . '/../../lib/GMapClientTestCache.class.php';
$gMapClient = new GMapClient('test');
$gMapClientTestCache = new GMapClientTestCache();
$gMapClient->setCache($gMapClientTestCache);
$t->diag('->geocode');
$t->is($gAddress->geocode($gMapClient), 8, 'Geocoded returned accuracy 8');
$t->is($gAddress->getLat(), 48.853795, 'Lat ok');
$t->is($gAddress->getLng(), 2.3369433, 'Lng ok');
$t->is($gAddress->getAccuracy(), 8, 'Accuracy ok');
$t->is($gAddress->geocodeXml($gMapClient), 8, 'Geocoded returned accuracy 8');
$t->is($gAddress->getLat(), 48.853795, 'Lat ok');
$t->is($gAddress->getLng(), 2.3369433, 'Lng ok');
$t->is($gAddress->getAccuracy(), 8, 'Accuracy ok');
$t->is($gAddress->getGeocodedAddress(), '60 Rue de Seine, 75006 Paris, France', 'Normalized address ok');
$t->is($gAddress->getGeocodedCity(), 'Paris', 'Normalized City ok');
$t->is($gAddress->getGeocodedCountry(), 'France', 'Normalized Country ok');
$t->is($gAddress->getGeocodedCountryCode(), 'FR', 'Normalized Country code ok');
$t->is($gAddress->getGeocodedPostalCode(), '75006', 'Normalized postal code ok');