Changeset 17898
- Timestamp:
- 05/03/09 18:19:40 (4 years ago)
- Files:
-
- plugins/sfEasyGMapPlugin/trunk/lib/GMap.class.php (modified) (1 diff)
- plugins/sfEasyGMapPlugin/trunk/lib/GMapBounds.class.php (modified) (1 diff)
- plugins/sfEasyGMapPlugin/trunk/lib/GMapCoord.class.php (modified) (2 diffs)
- plugins/sfEasyGMapPlugin/trunk/lib/GMapMarker.class.php (modified) (2 diffs)
- plugins/sfEasyGMapPlugin/trunk/modules/sfEasyGMapPlugin/actions/actions.class.php (modified) (1 diff)
- plugins/sfEasyGMapPlugin/trunk/modules/sfEasyGMapPlugin/templates/sample1Success.php (modified) (1 diff)
- plugins/sfEasyGMapPlugin/trunk/package.xml (modified) (1 diff)
- plugins/sfEasyGMapPlugin/trunk/test/unit/GMapTest.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfEasyGMapPlugin/trunk/lib/GMap.class.php
r17896 r17898 666 666 public function centerAndZoomOnMarkers($margin = 0) 667 667 { 668 $this->centerOnMarkers(); 668 669 $this->zoomOnMarkers($margin); 669 $this->centerOnMarkers();670 670 } 671 671 plugins/sfEasyGMapPlugin/trunk/lib/GMapBounds.class.php
r17896 r17898 155 155 } 156 156 157 /** 158 * Get the coordinates of the center of the zone 159 * 160 * @return GMapCoord 161 * @author fabriceb 162 * @since 2008-12-03 163 */ 164 public function getCenterCoord() 165 { 166 167 return new GMapCoord($this->getCenterLat(), $this->getCenterLng()); 168 } 169 157 170 /** 158 171 * Hauteur du carré plugins/sfEasyGMapPlugin/trunk/lib/GMapCoord.class.php
r17896 r17898 178 178 * @since 2009-05-02 179 179 */ 180 public static function get CenterCoord($coords)180 public static function getMassCenterCoord($coords) 181 181 { 182 182 if (count($coords)==0) … … 195 195 196 196 return new GMapCoord($center_lat/count($coords),$center_lng/count($coords)); 197 } 198 199 /** 200 * Calculates the center of an array of coordiantes 201 * 202 * @param GMapCoord[] $coords 203 * @return GMapCoord 204 * @author fabriceb 205 * @since 2009-05-02 206 */ 207 public static function getCenterCoord($coords) 208 { 209 $bounds = GMapBounds::getBoundsContainingCoords($coords); 210 211 return $bounds->getCenterCoord(); 197 212 } 198 213 plugins/sfEasyGMapPlugin/trunk/lib/GMapMarker.class.php
r17896 r17898 218 218 * 219 219 **/ 220 public static function get CenterCoord($markers)220 public static function getMassCenterCoord($markers) 221 221 { 222 222 $coords = array(); … … 226 226 } 227 227 228 return GMapCoord::getCenterCoord($coords); 228 return GMapCoord::getMassCenterCoord($coords); 229 } 230 231 /** 232 * 233 * @param GMapMarker[] $markers array of MArkers 234 * @return GMapCoord 235 * @author fabriceb 236 * @since 2009-05-02 237 * 238 **/ 239 public static function getCenterCoord($markers) 240 { 241 $bounds = GMapBounds::getBoundsContainingMarkers($markers); 242 243 return $bounds->getCenterCoord(); 229 244 } 230 245 plugins/sfEasyGMapPlugin/trunk/modules/sfEasyGMapPlugin/actions/actions.class.php
r16301 r17898 127 127 } 128 128 129 /** 130 * Here we learn to: 131 * - adapt the map to the current markers using complex but hidden formulas :-) 132 */ 133 public function executeSample4() 134 { 135 $this->gMap = new GMap(); 136 $this->gMap->setWidth(512); 137 $this->gMap->setHeight(400); 138 139 $this->gMap->addMarker( 140 new GMapMarker(51.245475,6.821373) 141 ); 142 $this->gMap->addMarker( 143 new GMapMarker(46.262248,6.115969) 144 ); 145 $this->gMap->addMarker( 146 new GMapMarker(48.848959,2.341577) 147 ); 148 $this->gMap->addMarker( 149 new GMapMarker(48.718952,2.219180) 150 ); 151 $this->gMap->addMarker( 152 new GMapMarker(47.376420,8.547995) 153 ); 154 $this->gMap->centerAndZoomOnMarkers(0.3); 155 156 $this->setTemplate('sample1'); 157 } 158 129 159 } plugins/sfEasyGMapPlugin/trunk/modules/sfEasyGMapPlugin/templates/sample1Success.php
r11741 r17898 2 2 3 3 <h1>The Map</h1> 4 <?php include_map($gMap ,array('width'=>'512px','height'=>'400px')); ?>4 <?php include_map($gMap); ?> 5 5 6 6 Search on the map: plugins/sfEasyGMapPlugin/trunk/package.xml
r17896 r17898 78 78 <file role="data" name="GMapBoundsTest.php" /> 79 79 <file role="data" name="GMapCoordTest.php" /> 80 <file role="data" name="GMapTest.php" /> 80 81 </dir> 81 82 </dir> plugins/sfEasyGMapPlugin/trunk/test/unit/GMapTest.php
r17896 r17898 45 45 $t->diag('->getMarkersCenterCoord test'); 46 46 47 $t->is($gMap->getMarkersCenterCoord()->__toString(),'48. 4904108, 5.2092188','The center of our markers is ok');47 $t->is($gMap->getMarkersCenterCoord()->__toString(),'48.7538615, 5.3835875','The center of our markers is ok'); 48 48 $gMap->centerOnMarkers(); 49 $t->is($gMap->getCenterCoord()->__toString(),'48. 4904108, 5.2092188','The center of the map is ok');49 $t->is($gMap->getCenterCoord()->__toString(),'48.7538615, 5.3835875','The center of the map is ok'); 50 50 51 51 $t->diag('->getMarkersFittingZoom test'); … … 56 56 57 57 $gMap->centerAndZoomOnMarkers(); 58 $t->is($gMap->getCenterCoord()->__toString(),'48. 4904108, 5.2092188','The center of the map is ok');58 $t->is($gMap->getCenterCoord()->__toString(),'48.7538615, 5.3835875','The center of the map is ok'); 59 59 $t->is($gMap->getZoom(),7,'The zoom of the map is ok'); 60 60