/**
  * 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());
 }
Exemplo n.º 2
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');
 }
/**
 * 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');
$t->is($gAddress->getGeocodedStreet(), '60 Rue de Seine', 'Normalized street ok');