Skip to content

Commit

Permalink
Added more map control through basic config options
Browse files Browse the repository at this point in the history
  • Loading branch information
mak001 committed Jul 28, 2022
1 parent f8f63a2 commit 9974837
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 5 deletions.
37 changes: 37 additions & 0 deletions docs/en/developerguide/customizing.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,43 @@ Dynamic\SilverStripeGeocoder\DistanceDataExtension:
unit_var: 'Unit'
```

#### Zoom, Minimum Zoom, and Maximum Zoom
To control zoom levels the following can be used:
```yaml
Dynamic\Locator\Page\LocatorController:
zoom: 11
```

There are also options for min and max zoom.
The minimum zoom is how far the map can zoom out, and the maximum zoom is how far the map can zoom in.
```yaml
Dynamic\Locator\Page\LocatorController:
min_zoom: 6
max_zoom: 18
```
A minimum zoom of 0 will allow the user to zoom to see the whole world.

#### Double Click Zoom
The following will allow zooming to be done with a double click.
```yaml
Dynamic\Locator\Page\LocatorController:
disable_double_click_zoom: false
```

#### Zoom With Scrollwheel
By default zooming with the mouse scroll wheel is disabled. It can be enabled with the following:
```yaml
Dynamic\Locator\Page\LocatorController:
scrollwheel: true
```

#### draggable
To make the map move on drag the following can be added:
```yaml
Dynamic\Locator\Page\LocatorController:
draggable: true
```

### Extenison Points

#### Locator Form
Expand Down
53 changes: 48 additions & 5 deletions src/pages/LocatorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,47 @@ class LocatorController extends \PageController
*/
private static $list_container = 'loc-list';

/**
* The zoom level of the map
* @var int
*/
private static $zoom = 12;

/**
* The minimum zoom level the map can have
* @var int
*/
private static $min_zoom = 6;

/**
* The maximum zoom level the map can have
* @var int
*/
private static $max_zoom = 18;

/**
* If double clicking the map should not zoom
* @var bool
*/
private static $disable_double_click_zoom = true;

/**
* If the map should disable zoom by scrollwheel
* @var bool
*/
private static $scrollwheel = false;

/**
* If the map should show naviagtion controls
* @var bool
*/
private static $navigation_control = false;

/**
* @var bool
*/
private static $draggable = false;

/**
* @var DataList|ArrayList
*/
Expand Down Expand Up @@ -105,12 +146,14 @@ public function init()
'defaultLat' => 0,
'defaultLng' => 0,
'mapSettings' => [
'zoom' => 12,
'zoom' => Config::inst()->get(LocatorController::class, 'zoom'),
'minZoom' => Config::inst()->get(LocatorController::class, 'min_zoom'),
'maxZoom' => Config::inst()->get(LocatorController::class, 'max_zoom'),
'mapTypeId' => 'google.maps.MapTypeId.ROADMAP',
'disableDoubleClickZoom' => true,
'scrollwheel' => false,
'navigationControl' => false,
'draggable' => false
'disableDoubleClickZoom' => Config::inst()->get(LocatorController::class, 'disable_double_click_zoom'),
'scrollwheel' => Config::inst()->get(LocatorController::class, 'scrollwheel'),
'navigationControl' => Config::inst()->get(LocatorController::class, 'navigation_control'),
'draggable' => Config::inst()->get(LocatorController::class, 'draggable'),
],
];

Expand Down

0 comments on commit 9974837

Please sign in to comment.