Skip to content

Commit

Permalink
updated docs (#165)
Browse files Browse the repository at this point in the history
  - includes example of requiring a different script.
  • Loading branch information
mak001 authored Jul 25, 2017
1 parent b0b5771 commit 8c1bc89
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
50 changes: 50 additions & 0 deletions docs/en/code/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#Extending

To change how the front-end javascript displays the map the custom script with the unique id `locator_map_init_script`.
This example shows how to reference custom templates and a custom data location. It is recommended to copy the custom script from the [Locator Controller](../../../code/pages/Locator.php#L273-L298) and modify it.

```php
class Locator_ControllerExtension extends Extension
{

public function onAfterInit()
{
$load = 'autoGeocode: false,
fullMapStart: true,';
$kilometer = ($this->owner->data()->Unit == 'km') ? "lengthUnit: 'km'" : "lengthUnit: 'm'";
$modal = ($this->owner->data()->ModalWindow) ? 'modalWindow: true' : 'modalWindow: false';

Requirements::customScript("
$(function(){
$('#map-container').storeLocator({
{$load}
dataLocation: '{$this->owner->Link()}SimpleXML.xml',
listTemplatePath: '{$this->owner->listTemplate}',
infowindowTemplatePath: '{$this->owner->windowTemplate}',
originMarker: true,
visibleMarkersList: false,
storeLimit: -1,
maxDistance: true,
slideMap: false,
distanceAlert: -1,
{$kilometer},
{$modal},
mapID: 'map',
locationList: 'loc-list',
mapSettings: {
zoom: 0,
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDoubleClickZoom: false,
scrollwheel: true,
navigationControl: false,
draggable: true
}
})
});",
"locator_map_init_script");
}
}
```

Please note that this will replace the script that is loaded.
More options for the javascript map options can be found [here](https://github.com/bjorn2404/jQuery-Store-Locator-Plugin).
4 changes: 3 additions & 1 deletion docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

See [User Guide](userguide/index.md) for information on using the Locator module in the CMS.

See [Importing Locations](userguide/import.md) for information on importing Location and Category records.
See [Importing Locations](userguide/import.md) for information on importing Location and Category records.

See [Extending](code/index.md) for information on how to extend some functionality.

0 comments on commit 8c1bc89

Please sign in to comment.