sfEasyGMapPlugin
3.1.0stable
for sf 1.3sf 1.2sf 1.1sf 1.0 MIT
The sfEasyGMap plugin provides helpers and an objet-oriented PHP abstraction to the Google Maps API.
It greatly eases the process of adding a Google Map and customising it in your symfony projects, without prior knowledge of the Google Maps API.
Two websites where it's used:
http://www.allomatch.com
http://apps.facebook.com/my-friends-map/
Feel free to comment on this work in progress on our blog:
http://www.theodo.fr/blog/
or report bugs on:
http://labs.theodo.fr/projects/sfeasygmapplugin/issues
IMPORTANT NOTE:
The main repository is now http://github.com/fabriceb/sfEasyGMapPlugin
To quickly contribute your patches, just fork the github branch and submit your commits to fabriceb
Developers
License
Copyright (c) 2008 Fabrice Bernhard
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Releases for sf 1.3
| Version |
License |
API |
Released |
|
3.1.0stable
|
MIT License |
3.1.0stable
|
20/11/2009 |
Releases for sf 1.2
| Version |
License |
API |
Released |
|
3.1.0stable
|
MIT License |
3.1.0stable
|
20/11/2009 |
|
3.0.0stable
|
MIT license |
3.0.0stable
|
16/10/2009 |
|
1.0.4stable
|
MIT license |
1.0.4stable
|
03/06/2009 |
|
1.0.3stable
|
MIT license |
1.0.3stable
|
03/05/2009 |
|
1.0.2stable
|
MIT license |
1.0.2stable
|
03/05/2009 |
|
1.0.1stable
|
MIT license |
1.0.1stable
|
15/03/2009 |
|
1.0.0stable
|
MIT license |
1.0.0stable
|
13/03/2009 |
|
0.9.4beta
|
MIT license |
0.9.4beta
|
13/03/2009 |
Releases for sf 1.1
| Version |
License |
API |
Released |
|
3.1.0stable
|
MIT License |
3.1.0stable
|
20/11/2009 |
|
3.0.0stable
|
MIT license |
3.0.0stable
|
16/10/2009 |
|
1.0.4stable
|
MIT license |
1.0.4stable
|
03/06/2009 |
|
1.0.3stable
|
MIT license |
1.0.3stable
|
03/05/2009 |
|
1.0.2stable
|
MIT license |
1.0.2stable
|
03/05/2009 |
|
1.0.1stable
|
MIT license |
1.0.1stable
|
15/03/2009 |
|
1.0.0stable
|
MIT license |
1.0.0stable
|
13/03/2009 |
|
0.9.4beta
|
MIT license |
0.9.4beta
|
13/03/2009 |
Releases for sf 1.0
| Version |
License |
API |
Released |
|
3.1.0stable
|
MIT License |
3.1.0stable
|
20/11/2009 |
|
3.0.0stable
|
MIT license |
3.0.0stable
|
16/10/2009 |
|
1.0.4stable
|
MIT license |
1.0.4stable
|
03/06/2009 |
|
1.0.3stable
|
MIT license |
1.0.3stable
|
03/05/2009 |
|
1.0.2stable
|
MIT license |
1.0.2stable
|
03/05/2009 |
|
1.0.1stable
|
MIT license |
1.0.1stable
|
15/03/2009 |
|
1.0.0stable
|
MIT license |
1.0.0stable
|
13/03/2009 |
|
0.9.4beta
|
MIT license |
0.9.4beta
|
13/03/2009 |
Changelog for release 3.1.0 - 20/11/2009
- corrected package.xml
- added GMapDirections functionalities
Other releases
Release 3.1.0 - 20/11/2009
- corrected package.xml
- added GMapDirections functionalities
Release 3.0.0 - 16/10/2009
- Added nice samples
- Use the Google Map API v3
Release 1.0.4 - 03/06/2009
- Added a very practical function $gMap->getBoundsFromCenterAndZoom(...) which enables one to calculate server-side the bounds corresponding to specific center coordinates, zoom, and map size. This is the equivalent client-side of map.setCenter(...,...);map.setZoom(...);map.getBounds(); It uses Mercator projection formulas as used by the Google Maps
- A new function function $gMapMarker->isInsideBounds($bounds)
- Corresponding Unit tests
- And a new sample using the two last functionalities
Release 1.0.3 - 03/05/2009
- Added tomr's contribution: it is now possible to add multiple controls to the map
- Also bundled with GMapCoord::distance($coord1, $coord2) function which gives an estimation of the distance between two coordinates
Release 1.0.2 - 03/05/2009
- Corrected the Mercator projections for the GMapCoord::fromPixToLat and GMapCoord::fromLatToPix functions
- Used PHP pi() and deg2rad functions for better precision
- Created tests for the Mercator projections
- Added the GMapBounds::getBoundsContainingMarkers($markers) function
- Added the GMap::centerAndZoomOnMarkers() function which enables to guess zoom and center of the map to fit the markers. Center is easy to guess. Zoom uses width and height of smallest bound, pixel width and height of the map and Mercator projection
Release 1.0.1 - 15/03/2009
- fabriceb: Corrected the package.xml to add all 1.2.x versions of symfony to the list of compatible versions
Release 1.0.0 - 13/03/2009
- WARNING: backwards-compatibility is broken
- The GMap constructor now takes an option array as first parameter
- added some unit tests
- added some very interesting functions concerning bounds : Smallest bound containing coords, homthety transformation, zoomOut, Propel criteria "In bounds"
- added some very interesting functions concerning coordinates : you can now transform lat/lng into Google Map' pixels coordinates system and vice-versa. This enables one to calculate the bounds around a coordinate for example, knowing only the Google Map's height/width in pixels
Release 0.9.4 - 13/03/2009
- removed the call to the Helper Tag to use the escape_javascript function to ensure symfony 1.2 compatibility
sfEasyGMapPlugin
The sfEasyGMap plugin provides helpers and an objet-oriented PHP
abstraction to the Google Maps API to ease the process of adding a
Google Map and customising it in your symfony projects.
Installation
Install the plugin
$ symfony plugin:install sfEasyGMapPlugin (Not tested)
or in your plugins directory :
$ svn co http://svn.symfony-project.com/plugins/sfEasyGMapPlugin/branches/v3 sfEasyGMapPlugin
Optional: enable the sample module in your settings.yml: sfEasyGMapPlugin
[php]
all:
.settings:
enabled_modules: [default, sfEasyGMapPlugin]
Clear your cache
$ php symfony cc
Examples
All samples are available in the sfEasyGMapPlugin module of the plugin (/sfEasyGMapPlugin/index)
IMPORTANT ! The javascript in the samples will not work unless you put the js files in your web directory.
$ ln -s ../plugins/sfEasyGMapPlugin/web web/sfEasyGMapPlugin
or use the symfony command :
$ php symfony plugin:publish-assets
Sample 1
Add some markers on a map, using longitudes and latitudes
In the action:
$this->gMap = new GMap();
$this->gMap->addMarker(new GMapMarker(51.245475,6.821373));
$this->gMap->addMarker(new GMapMarker(46.262248,6.115969));
In the template:
<?php use_helper('Javascript','GMap') ?>
<?php include_map($gMap,array('width'=>'512px','height'=>'400px')); ?>
<!-- Javascript included at the bottom of the page -->
<?php include_map_javascript($gMap); ?>
Sample 2
Geocode some addresses and open an info window if the user clicks on a marker
In the action:
$this->gMap = new GMap();
// some places in the world
$addresses = array(
'Graf-Recke-Strasse 220 - 40237 Düsseldorf',
'Avenue des sports 01210 FERNEY-VOLTAIRE - FRANCE',
'44 boulevard Saint-Michel, Paris',
'Route Saclay 91120 Palaiseau',
'Rämistrasse 101, Zürich'
);
foreach ($addresses as $address)
{
$geocoded_address = $this->gMap->geocode($address);
$gMapMarker = new GMapMarker($geocoded_address->getLat(),$geocoded_address->getLng());
$gMapMarker->addHtmlInfoWindow('<b>Address:</b><br />'.$address);
$this->gMap->addMarker($gMapMarker);
}
In the template:
<?php use_helper('Javascript','GMap') ?>
<?php include_map($gMap,array('width'=>'512px','height'=>'400px')); ?>
<!-- Javascript included at the bottom of the page -->
<?php include_map_javascript($gMap); ?>
TODO
- correct javascript files that suppose that the map's javascript object is called 'map'
- add support for EncodedLines
- add support for custom zoom and move controls
- add support for Directions
- add support for Labeled markers