Hi all.
I'm trying to implement a Google Maps pattern for editing and storing a location (s). Currently I'm doing the following to include the google maps js in the pattern:
require([
"jquery",
"pat-base",
"https://maps.googleapis.com/maps/api/js?libraries=places&key={myKey}"
], function($, Base) {
"use strict";
var Location = Base.extend({
name: "location",
parser: "mockup",
trigger: ".location",
default: {
...
}
},
init: function() {
...
}
}
My issue is that I now need the API key to be configurable. Ideally, this would be done though data-pat-location
. My js is quite rough around the edges, and the concept of mockup/ patterns is a new one to me.
How can I require the googlemaps js but use data-pat to configure the api key in the url? Is patterns even the write way of implementing this or is there a better way of bundling the needed js for use across multiple pages/ page-templates and ensuring it's only included once in a page?
I'm aware of collective.geo, but it isn't suited to the needs of this project.