Skip to content

Commit

Permalink
Merge pull request #1 from tumapav/ft-extraTileControl
Browse files Browse the repository at this point in the history
Add extraTileControl() for more customisation
  • Loading branch information
onexer committed Mar 10, 2022
2 parents 5315ac7 + bd96507 commit 9925e4f
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Option | Type | Default | Description
`tilesUrl(string)` | string | http://tile.openstreetmap.org/{z}/{x}/{y}.png | Tiles service/provider url.
`showZoomControl(bool)` | bool | false | Show or hide Zoom control of the map.
`extraControl(array)` | array | [] | Add extra map controls (please refer to leaflet)
`extraTileControl(array)` | array | [] | Add extra tileLayer controls (please refer to leaflet tileLayer())

# License

Expand Down
2 changes: 1 addition & 1 deletion dist/humaidem/map-picker/map-picker.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/humaidem/map-picker/map-picker.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/humaidem/map-picker/map-picker.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/humaidem/map-picker/map-picker.js": "/humaidem/map-picker/map-picker.js?id=d5e65ec4a2c166edb3a2",
"/humaidem/map-picker/map-picker.css": "/humaidem/map-picker/map-picker.css?id=cd5eec2b100f31b86f69"
"/humaidem/map-picker/map-picker.js": "/humaidem/map-picker/map-picker.js?id=57589bc2fe7dc1200c752294a060d243",
"/humaidem/map-picker/map-picker.css": "/humaidem/map-picker/map-picker.css?id=016942598af1e431d1cc4e25b89f2809"
}
8 changes: 5 additions & 3 deletions resources/js/map-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ window.mapPicker = ($wire, config) => {
}

this.tile = L.tileLayer(config.tilesUrl, {
attribution: null,
attribution: config.attribution,
minZoom: config.minZoom,
maxZoom: config.maxZoom,
tileSize: 512,
zoomOffset: -1
tileSize: config.tileSize,
zoomOffset: config.zoomOffset,
detectRetina: config.detectRetina,
}).addTo(this.map);


Expand Down
25 changes: 21 additions & 4 deletions src/Fields/OSMMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ class OSMMap extends Field implements MapOptions
* @var array
*/
private array $mapConfig = [
'statePath' => '',
'draggable' => false,
'showMarker' => false,
'tilesUrl' => 'http://tile.openstreetmap.org/{z}/{x}/{y}.png',
'statePath' => '',
'draggable' => false,
'showMarker' => false,
'tilesUrl' => 'http://tile.openstreetmap.org/{z}/{x}/{y}.png',
'attribution' => null,
'zoomOffset' => -1,
'tileSize' => 512,
'detectRetina' => false,
'minZoom' => 0,
'maxZoom' => 18,
];

/**
Expand Down Expand Up @@ -153,6 +159,17 @@ public function extraControl(array $control): self
return $this;
}

/**
* Append extra controls to be passed to leaflet tileLayer object
* @param array $control
* @return $this
*/
public function extraTileControl(array $control): self
{
$this->mapConfig = array_merge($this->mapConfig, $control);
return $this;
}

public function hasJs(): bool
{
return true;
Expand Down
2 changes: 2 additions & 0 deletions src/Interfaces/MapOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public function showZoomControl(bool $show = true): self;

public function extraControl(array $control): self;

public function extraTileControl(array $control): self;

public function hasJs(): bool;

public function jsUrl(): string;
Expand Down

0 comments on commit 9925e4f

Please sign in to comment.