I'm in a project using Marko.js with Lasso.js for building .js and .scss code. I can successfully interact with Google Maps API through <script>
tags. I wish to send latitude and longitude values to other templates, how do I do this?
I tried using this guide inside the docs but it didn't work. I tried to reference a global variable from an index.marko
with inline js inside a <script>
tag.
The reason I'm forced to use inline js has to do with Lasso.js and Google Maps using <script async defer src='https://maps.googleapis.com/maps/api/...&callback=initMap'/>
, it has a callback to an inline js function called initMap() inside another <script>
tag. Every time I tried to move the inline js code to an individual .js file, by adding it to the browser.json
file like everything else. It throws an error saying that there is no initMap function loaded.
Ok so here is my root directory
src
|_ pages
|_ home
|_ index.marko
|_ index.js
src
|_ components
|_ location-search
|_ index.marko
This is location-search/index.marko:
div.search-container.location-search
div.input-field
p.input-label -- Search
input.controls#pac-input type="text" placeholder="Search Box"
div#map
<script>
functioninitMap() {
// Do Google Maps stuff and obtain an array of lat lng values.
}
</script>
<script async defer src="https://maps.googleapis.com/maps/api/...&callback=initMap"/>
This is home/index.marko
lasso-page package-path="./browser.json"
<!DOCTYPE html>
html lang="en"
head
meta charset="UTF-8"
meta name="viewport" content="initial-scale=1.0"
meta http-equiv="X-UA-Compatible" content="ie=edge"
title -- App
lasso-head
body
location-search
browser-refresh
lasso-body
I expect to be able to access from another page the array of latitude and longitude values obtained in components/location-search/index.marko.
Marko is a great tool, it just needs more documentation. Thanks in advance.