-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- includes example of requiring a different script.
- Loading branch information
Showing
2 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters