I thought i could easily turn a js script into a node module. But i find out that isn’t so easy.
I created a trafficmap on the maps api page and from there i created this. I pasted the straightforward code.
I tried many thing but honestly i don’t know where to start.
Anyone can help me make this work? After that i could create the config options like api key and location.
Finally i want it to open and close with the voice control module ^^. To open the map of location from home to work. And another voice command for my girlfriends home to work.
Here is my trafficmaps.js
Module.register("trafficmaps",{
// Default module config.
defaults: {
text: "",
animationSpeed: 500,
},
start: function() {
this.sendSocketNotification("CONNECT", {});
},
<div id="map"></div>
<!-- Replace the value of the key parameter with your own API key. -->
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk&callback=initMap">
</script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 13,
center: {lat: 34.04924594193164, lng: -118.24104309082031},
styles:[
{
"featureType": "administrative",
"stylers": [
{ "visibility": "on" },
{ "invert_lightness": true },
{ "saturation": -100 }
]
},{
"featureType": "landscape",
"stylers": [
{ "visibility": "on" },
{ "invert_lightness": true },
{ "saturation": -100 }
]
},{
"featureType": "poi",
"stylers": [
{ "visibility": "on" },
{ "invert_lightness": true },
{ "saturation": -100 }
]
},{
"featureType": "transit",
"stylers": [
{ "visibility": "on" },
{ "invert_lightness": true },
{ "saturation": -100 }
]
},{
"featureType": "water",
"stylers": [
{ "saturation": -100 },
{ "visibility": "on" },
{ "invert_lightness": true }
]
},{
"featureType": "road.highway",
"elementType": "geometry",
"stylers": [
{ "visibility": "on" },
{ "invert_lightness": true },
{ "saturation": -100 }
]
},{
"featureType": "road.arterial",
"stylers": [
{ "invert_lightness": true },
{ "saturation": -100 },
{ "visibility": "off" }
]
},{
"featureType": "road.local",
"stylers": [
{ "visibility": "off" },
{ "invert_lightness": true },
{ "saturation": -100 }
]
},{
"featureType": "road",
"elementType": "labels.icon",
"stylers": [
{ "saturation": -100 },
{ "gamma": 0.48 },
{ "visibility": "on" }
]
},{
"featureType": "traffic",
"stylers": [
{ "saturation": -100 },
{ "gamma": 0.48 },
{ "visibility": "on" }
]
}
]
});
var trafficLayer = new google.maps.TrafficLayer();
trafficLayer.setMap(map);
}
// Override dom generator.
getDom: function() {
var wrapper = document.createElement("div");
wrapper.innerHTML = this.config.text;
return wrapper;
}
});