Skip to content

Commit 46f6b94

Browse files
authored
Merge pull request #110 from Heyian/MapStyle
Added capability to choose map style
2 parents d87afad + d862214 commit 46f6b94

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ use Cheesegrits\FilamentGoogleMaps\Fields\Map
358358
->defaultLocation([39.526610, -107.727261]) // default for new forms
359359
->draggable() // allow dragging to move marker
360360
->clickable(false) // allow clicking to move marker
361+
->mapType('roadmap') // map type (hybrid, satellite, roadmap, terrain)
361362
->geolocate() // adds a button to request device location and set map marker accordingly
362363
->geolocateLabel('Get Location') // overrides the default label for geolocate button
363364
->geolocateOnLoad(true, false) // geolocate on load, second arg 'always' (default false, only for new form))

dist/cheesegrits/filament-google-maps/filament-google-maps-widget.js

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/cheesegrits/filament-google-maps/filament-google-maps.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/filament-google-maps.js

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export default function filamentGoogleMapsField({
7070
placeUpdatedUsing,
7171
hasReverseGeocodeUsing = false,
7272
hasPlaceUpdatedUsing = false,
73+
mapType = 'roadmap',
7374
}) {
7475
return {
7576
state,
@@ -151,6 +152,7 @@ export default function filamentGoogleMapsField({
151152
this.map = new google.maps.Map(mapEl, {
152153
center: this.getCoordinates(),
153154
zoom: defaultZoom,
155+
mapTypeId: google.maps.MapTypeId[mapType.toUpperCase()],
154156
...controls,
155157
});
156158

resources/views/fields/filament-google-maps.blade.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
pacEl: $refs.pacinput,
5454
polyOptions: @js($getPolyOptions()),
5555
circleOptions: @js($getCircleOptions()),
56-
rectangleOptions: @js($getRectangleOptions())
56+
rectangleOptions: @js($getRectangleOptions()),
57+
mapType: @js($getMapType()),
5758
})"
5859
id="{{ $getId() . '-alpine' }}"
5960
wire:ignore

src/Fields/Map.php

+17
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ class Map extends Field
7171

7272
protected ?Closure $placeUpdatedUsing = null;
7373

74+
protected Closure|string $mapType = 'roadmap';
75+
7476
protected Closure|array $drawingModes = [
7577
'marker' => true,
7678
'circle' => true,
@@ -822,6 +824,7 @@ public function getMapConfig(): string
822824
'polyOptions' => $this->getPolyOptions(),
823825
'rectangleOptions' => $this->getRectangeOptions(),
824826
'circleOptions' => $this->getCircleOptions(),
827+
'mapType' => $this->getMapType(),
825828
]);
826829

827830
//ray($config);
@@ -879,4 +882,18 @@ public function getCircleOptions(): ?array
879882
{
880883
return $this->evaluate($this->circleOptions);
881884
}
885+
886+
public function mapType(Closure|string $mapType): static
887+
{
888+
$this->mapType = $mapType;
889+
890+
return $this;
891+
}
892+
893+
public function getMapType(): string
894+
{
895+
return $this->evaluate($this->mapType);
896+
}
897+
898+
882899
}

0 commit comments

Comments
 (0)