This repository has been archived by the owner on Aug 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated coding standards of existing code, added new functionality (map points, new GSM features). Extra examples and github docs.
- Loading branch information
Showing
14 changed files
with
1,617 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nbproject/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,45 @@ | ||
php-static-maps-generator | ||
========================= | ||
|
||
A PHP library to generate Google Static Map Links | ||
A PHP library to generate Google Static Map Links. The Google Static Maps Library (V2) is a free service, [made available by Google] (https://developers.google.com/maps/documentation/staticmaps/). | ||
|
||
Using simple OO methods, this project will build the URL which can be used in an image tag. | ||
|
||
|
||
Example Code: | ||
------------- | ||
|
||
include('../googlestaticmap.php'); | ||
|
||
$oSstaticMap = new GoogleStaticMap(); | ||
$oSstaticMap ->setCenter("London,UK") | ||
->setHeight(300) | ||
->setWidth(232) | ||
->setZoom(8) | ||
->setHttps(true) | ||
->setFormat("jpg") | ||
->setFeatureStyling(array( | ||
"feature"=>"all", | ||
"element"=>"all", | ||
"style"=>array( | ||
"saturation"=>-53, | ||
"gamma"=>4.88, | ||
"lightness"=>16, | ||
"hue"=>"#1aff00" | ||
) | ||
)); | ||
|
||
echo '<img src="' . $oSstaticMap . '" height="' . $oSstaticMap->getHeight() . '" width="' . $oSstaticMap->getWidth() . '" />'; | ||
|
||
Example Output: | ||
--------------- | ||
|
||
![Sample map generated by the Class](http://maps.google.com/maps/api/staticmap?center=&zoom=10&language=en-GB&maptype=hybrid&format=png8&size=600x600&scale=1&path=weight:5|color:0x00000000|fillcolor:0xFFFF0033|51.855376,-0.576904|Wembley%2C+UK|Barnet%2C+UK&sensor=false) | ||
|
||
|
||
|
||
Requirements: | ||
------------- | ||
This library requires no additional software beyond a functional version of PHP | ||
5.2 (or greater) and if you wish to retrieve the Map image, a working Internet | ||
connection. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/* | ||
* Generates a 300x232 pixel google map, centered over london, using an HTTPS | ||
* connection | ||
*/ | ||
|
||
include('../googlestaticmap.php'); | ||
include('../googlestaticmapfeature.php'); | ||
include('../googlestaticmapfeaturestyling.php'); | ||
include('../googlestaticmapmarker.php'); | ||
include('../googlestaticmappath.php'); | ||
include('../googlestaticmappathpoint.php'); | ||
|
||
$oStaticMap = new GoogleStaticMap(); | ||
$oStaticMap->setCenter("London,UK") | ||
->setHeight(300) | ||
->setWidth(232) | ||
->setZoom(8) | ||
->setHttps(true); | ||
|
||
echo '<img src="' . $oStaticMap . '" height="' . $oStaticMap->getHeight() . '" width="' . $oStaticMap->getWidth() . '" />'; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/* | ||
* Generates a 300x232 pixel google map, centered over london, | ||
* with light green features. | ||
*/ | ||
|
||
include('../googlestaticmap.php'); | ||
include('../googlestaticmapfeature.php'); | ||
include('../googlestaticmapfeaturestyling.php'); | ||
include('../googlestaticmapmarker.php'); | ||
include('../googlestaticmappath.php'); | ||
include('../googlestaticmappathpoint.php'); | ||
|
||
$oStaticMap = new GoogleStaticMap(); | ||
$oStaticMap->setCenter("London,UK") | ||
->setHeight(300) | ||
->setWidth(232) | ||
->setZoom(8) | ||
->setFormat("jpg") | ||
->setFeatureStyling(array( | ||
"feature" => "all", | ||
"element" => "all", | ||
"style" => array( | ||
"hue" => "#006400", //Green features | ||
"lightness" => 50 //Very light... | ||
) | ||
)); | ||
|
||
echo '<img src="' . $oStaticMap . '" height="' . $oStaticMap->getHeight() . '" width="' . $oStaticMap->getWidth() . '" />'; | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
/* | ||
* Generates a 300x232 pixel google map, centered over london, | ||
* with feature styling and a medium marker placed off centre. | ||
*/ | ||
|
||
include('../googlestaticmap.php'); | ||
include('../googlestaticmapfeature.php'); | ||
include('../googlestaticmapfeaturestyling.php'); | ||
include('../googlestaticmapmarker.php'); | ||
include('../googlestaticmappath.php'); | ||
include('../googlestaticmappathpoint.php'); | ||
|
||
$oStaticMap = new GoogleStaticMap(); | ||
$oStaticMap->setCenter('London,UK') | ||
->setHeight(300) | ||
->setWidth(232) | ||
->setZoom(8) | ||
->setMapType('hybrid') | ||
->setFormat('png'); | ||
|
||
$oStaticMap->setMarker(array( | ||
'color' => 'blue', | ||
'size' => 'mid', | ||
'longitude' => -0.062004, | ||
'latitude' => 51.462564, | ||
'label' => 'b' | ||
)); | ||
|
||
echo '<img src="' . $oStaticMap . '" height="' . $oStaticMap->getHeight() . '" width="' . $oStaticMap->getWidth() . '" />'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/* | ||
* Generates a 300x232 pixel google map, centered over london, using an HTTPS | ||
* connection, 2 markers (Med & Large) with labels. | ||
*/ | ||
|
||
include('../googlestaticmap.php'); | ||
include('../googlestaticmapfeature.php'); | ||
include('../googlestaticmapfeaturestyling.php'); | ||
include('../googlestaticmapmarker.php'); | ||
include('../googlestaticmappath.php'); | ||
include('../googlestaticmappathpoint.php'); | ||
|
||
$oStaticMap = new GoogleStaticMap(); | ||
$oStaticMap->setCenter('London,UK') | ||
->setHeight(300) | ||
->setWidth(300) | ||
->setZoom(8) | ||
->setMapType('hybrid') | ||
->setFormat('png'); | ||
|
||
$oStaticMap->setMarker(array( | ||
'color' => 'blue', | ||
'size' => 'mid', | ||
'longitude' => -0.062004, | ||
'latitude' => 51.462564, | ||
'label' => 'C' | ||
)); | ||
|
||
$oMarker = new GoogleStaticMapMarker(); | ||
$oMarker->setColor('red') | ||
->setSize('large') | ||
->setLongitude(-0.576904) | ||
->setLatitude(51.855376) | ||
->setLabel('B'); | ||
|
||
$oStaticMap->setMarker($oMarker); | ||
|
||
echo '<img src="' . $oStaticMap . '" height="' . $oStaticMap->getHeight() . '" width="' . $oStaticMap->getWidth() . '" />'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
/* | ||
* Generates a 600x600 pixel google map, centered over 2 path points, 1 defined | ||
* using coordinates, the other using a string. Scale set to 2 (double resolution) | ||
*/ | ||
|
||
include('../googlestaticmap.php'); | ||
include('../googlestaticmapfeature.php'); | ||
include('../googlestaticmapfeaturestyling.php'); | ||
include('../googlestaticmapmarker.php'); | ||
include('../googlestaticmappath.php'); | ||
include('../googlestaticmappathpoint.php'); | ||
|
||
$oStaticMap = new GoogleStaticMap(); | ||
$oStaticMap->setHeight(600) | ||
->setWidth(600) | ||
->setMapType('hybrid') | ||
->setFormat('jpg') | ||
->setScale(2); | ||
|
||
//Create Path Object and set styling | ||
$oPath = new GoogleStaticMapPath(); | ||
$oPath->setColor('red') | ||
->setWeight(5); | ||
|
||
//Create Path Point | ||
$oPathPoint = new GoogleStaticMapPathPoint(); | ||
$oPathPoint->setLatitude(51.855376) | ||
->setLongitude(-0.576904); | ||
$oPath->setPoint($oPathPoint); | ||
|
||
//Create Another Path Point | ||
$oPathPoint2 = new GoogleStaticMapPathPoint(); | ||
$oPathPoint2->setLocation('Wembley, UK'); | ||
$oPath->setPoint($oPathPoint2); | ||
|
||
//Add Points to Map | ||
$oStaticMap->setMapPath($oPath); | ||
|
||
echo '<img src="' . $oStaticMap . '" height="' . $oStaticMap->getHeight() * 2 . '" width="' . $oStaticMap->getWidth() * 2 . '" />'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/* | ||
* Generates a 600x600 pixel google map, centered over 3 path points, 1 defined | ||
* using coordinates, the other 2 using a string. The path is filled, as there | ||
* are more than 2 with a transparent yellow. | ||
*/ | ||
|
||
include('../googlestaticmap.php'); | ||
include('../googlestaticmapfeature.php'); | ||
include('../googlestaticmapfeaturestyling.php'); | ||
include('../googlestaticmapmarker.php'); | ||
include('../googlestaticmappath.php'); | ||
include('../googlestaticmappathpoint.php'); | ||
|
||
$oStaticMap = new GoogleStaticMap(); | ||
$oStaticMap->setHeight(600) | ||
->setWidth(600) | ||
->setMapType('hybrid') | ||
->setFormat('png8'); | ||
|
||
|
||
//Create Path Object and set styling | ||
$oPath = new GoogleStaticMapPath(); | ||
$oPath->setColor('0x00000000') | ||
->setWeight(5) | ||
->setFillColor('0xFFFF0033'); | ||
|
||
//Create Point | ||
$oPathPoint = new GoogleStaticMapPathPoint(); | ||
$oPathPoint->setLatitude(51.855376) | ||
->setLongitude(-0.576904); | ||
$oPath->setPoint($oPathPoint); | ||
|
||
//Create Another Path Point | ||
$oPathPoint2 = new GoogleStaticMapPathPoint(); | ||
$oPathPoint2->setLocation('Wembley, UK'); | ||
$oPath->setPoint($oPathPoint2); | ||
|
||
//Create Another Path Point | ||
$oPathPoint3 = new GoogleStaticMapPathPoint(); | ||
$oPathPoint3->setLocation('Barnet, UK'); | ||
$oPath->setPoint($oPathPoint3); | ||
|
||
//Add Points to Map | ||
$oStaticMap->setMapPath($oPath); | ||
|
||
echo '<img src="' . $oStaticMap . '" height="' . $oStaticMap->getHeight() . '" width="' . $oStaticMap->getWidth() . '" />'; |
Oops, something went wrong.