Skip to content

Instantly share code, notes, and snippets.

@nielsnuebel
Created January 22, 2019 07:41
Show Gist options
  • Save nielsnuebel/2997d3d07dbb6cd79356b78d72f84465 to your computer and use it in GitHub Desktop.
Save nielsnuebel/2997d3d07dbb6cd79356b78d72f84465 to your computer and use it in GitHub Desktop.
/**
* Method to set up the document properties
*
* @return void
*/
protected function setDocument()
{
$compparams = JComponentHelper::getParams('com_xxx);
$lat = $compparams->get('lat', 53.54520363618777);
$lng = $compparams->get('lng', 9.9755859375);
$mapsapi = $compparams->get('maps_api', 123456789);
$zoom = $compparams->get('zoom', 13);
$scrollwheel = $compparams->get('scrollwheel', 1);
$isNew = $this->item->id == 0;
if (!$isNew and $this->item->lat != "" and $this->item->lat != "")
{
$lat = $this->item->lat;
$lng = $this->item->lng;
}
$document = JFactory::getDocument();
$document->addStylesheet('../media/com_xxx/css/leaflet.css');
$document->addScript('../media/com_xxx/js/leaflet.js');
$document->addScript('../media/com_xxx/createMarkerleaflet.js');
$js = 'jQuery(function(){';
$js .= "jQuery('#map').addMarker(
{
lat: " . $lat . ",
lng: " . $lng . ",
zoom: " . $zoom . ",
scrollwheel: " . $scrollwheel . "
}
);";
$js .= '});';
$document->addScriptDeclaration($js);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment