Skip to content

Commit

Permalink
Adding attribution
Browse files Browse the repository at this point in the history
  • Loading branch information
Franck ALARY committed Sep 9, 2021
1 parent 0468194 commit 018fd49
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ use \DantSu\FrenchCadastralMapStaticAPI\Markers;
FrenchCadastralMap::LAYER_HYDRO,
FrenchCadastralMap::LAYER_BUILDING,
FrenchCadastralMap::LAYER_BORNE_REPERE,
FrenchCadastralMap::LAYER_VOIE_COMMUNICATION,
// FrenchCadastralMap::LAYER_VOIE_COMMUNICATION,
// FrenchCadastralMap::LAYER_LIEUDIT
])
->setDisplayOpenStreetMap(true)
->addMarkers(
(new Markers(__DIR__ . '/resources/marker.png'))
->setAnchor(Markers::ANCHOR_CENTER, Markers::ANCHOR_BOTTOM)
->addMarker(new LatLng(44.351933, 2.568113))
->addMarker(new LatLng(44.351510, 2.570020))
->addMarker(new LatLng(44.351873, 2.566250))
)
->addLine(
(new Line('FF0000', 2))
Expand Down
9 changes: 7 additions & 2 deletions src/FrenchCadastralMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class FrenchCadastralMap extends OpenStreetMap
*/
private $layers = [];
/**
* @var bool is displaying Open Street Map
* @var bool is displaying OpenStreetMap
*/
private $displayOpenStreetMap = false;

Expand Down Expand Up @@ -78,12 +78,17 @@ public function setDisplayOpenStreetMap(bool $displayOpenStreetMap): FrenchCadas
return $this;
}

protected function getAttributionText()
{
return 'cadastre.gouv.fr' . ($this->displayOpenStreetMap ? ' - ' . parent::getAttributionText() : '');
}

/**
* Get only the map image.
* @see https://github.com/DantSu/php-image-editor See more about DantSu\PHPImageEditor\Image
* @return Image An instance of DantSu\PHPImageEditor\Image
*/
public function getMapImage(): Image
protected function getMapImage(): Image
{
$bbox = $this->getBoundingBox();

Expand Down
Binary file modified src/samples/resources/sample1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion src/samples/sample1.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<?php
require_once '../../vendor/autoload.php';
require_once '../FrenchCadastralMap.php';
require_once '../LatLng.php';
require_once '../Line.php';
require_once '../Markers.php';
require_once '../XY.php';

use \DantSu\FrenchCadastralMapStaticAPI\FrenchCadastralMap;
use \DantSu\FrenchCadastralMapStaticAPI\LatLng;
Expand All @@ -16,14 +22,16 @@
FrenchCadastralMap::LAYER_HYDRO,
FrenchCadastralMap::LAYER_BUILDING,
FrenchCadastralMap::LAYER_BORNE_REPERE,
FrenchCadastralMap::LAYER_VOIE_COMMUNICATION,
// FrenchCadastralMap::LAYER_VOIE_COMMUNICATION,
// FrenchCadastralMap::LAYER_LIEUDIT
])
->setDisplayOpenStreetMap(true)
->addMarkers(
(new Markers(__DIR__ . '/resources/marker.png'))
->setAnchor(Markers::ANCHOR_CENTER, Markers::ANCHOR_BOTTOM)
->addMarker(new LatLng(44.351933, 2.568113))
->addMarker(new LatLng(44.351510, 2.570020))
->addMarker(new LatLng(44.351873, 2.566250))
)
->addLine(
(new Line('FF0000', 2))
Expand Down

0 comments on commit 018fd49

Please sign in to comment.