I am developing a Joomla 3.x content plugin to display Openlayer maps in articles based on @Robbie Jacksons excellent tutorial at https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Adding_a_Map and I managed to make it work. However, in Robbie's tutorial he includes the full Openlayers library which is discouraged for production sites:
// everything's dependent upon JQuery JHtml::_('jquery.framework'); // we need the Openlayers JS and CSS libraries $document->addScript("https://cdnjs.cloudflare.com/ajax/libs/openlayers/4.6.4/ol.js"); $document->addStyleSheet("https://cdnjs.cloudflare.com/ajax/libs/openlayers/4.6.4/ol.css");
I ran into a number of problems when trying to put the transpiled bundle into my Joomla extension:
<script>tag just before the final
</body>tag. But you do not want it to run until the DOM-tree is ready, otherwise it will fail.
$document->addScriptOptions()and then you retrive the options client side using e.g. var