-
Notifications
You must be signed in to change notification settings - Fork 15
/
travelmap.min.js
7 lines (7 loc) · 3.44 KB
/
travelmap.min.js
1
2
3
4
5
6
7
//! travelmap.js
//! version : 1.0.2
//! authors : Shawn Wildermuth
//! license : MIT
//! repo : https://github.com/shawnwildermuth/travelmap
(function(){"use strict";var o={},t={stops:[],currentStop:0,selector:"#map",icon:{url:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAAGCAIAAABvrngfAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjExR/NCNwAAAA1JREFUGFdjoDNgYAAAAHIAAejt7scAAAAASUVORK5CYII=",width:3,height:3},initialZoom:4,pastStroke:{color:"#190300",opacity:.5,weight:2},futureStroke:{color:"#D30000",opacity:.6,weight:2},mapOptions:{draggable:!0,scrollwheel:!1,disableDoubleClickZoom:!0,zoomControl:!0},overlay:{className:"travelmap-overlay"}};o.createMap=function(o){var e,i=n(o,t);if(!i.stops||0==i.stops.length)throw"You must supply stops when creating a map.";var l=i.stops.slice(0,i.currentStop+1),p=i.stops.slice(i.currentStop,i.stops.length),s=i.stops[i.currentStop];a(),"function"==typeof window.GMaps&&window.GMaps||console.log("GMaps (and Google Maps API) is required. Please register the following JavaScript library https://hpneo.github.io/gmaps/documentation.html"),e=new GMaps({div:i.selector,lat:s.lat,lng:s["long"],zoom:i.initialZoom}),e.map.setOptions(i.mapOptions),e.drawPolyline({path:r(l),strokeColor:i.pastStroke.color,strokeOpacity:i.pastStroke.opacity,strokeWeight:i.pastStroke.weight}),e.drawPolyline({path:r(p),strokeColor:i.futureStroke.color,strokeOpacity:i.futureStroke.opacity,strokeWeight:i.futureStroke.weight});for(var c=0;c<i.stops.length;++c){var d=i.stops[c];c!=i.currentStop&&e.addMarker({lat:d.lat,lng:d["long"],icon:i.icon.url,infoWindow:{content:d.info},anchorPoint:{x:i.icon.width/2,y:i.icon.height/2}})}return e.drawOverlay({lat:s.lat,lng:s["long"],content:'<div class="'+i.overlay.className+'">Current Location<br/>'+s.info+'<div class="'+i.overlay.className+"-arrow "+i.overlay.className+'-arrow-above"></div></div>',verticalAlign:"top",horizontalAlign:"center",layer:"overlayImage"}),{map:e,settings:i,currentLocation:s}};var e=function(o){return[o.lat,o["long"]]},r=function(o){for(var t=[],r=0;r<o.length;++r)t.push(e(o[r]));return t},a=function(){var o=".stopName { background: none repeat scroll 0 0 #222; width: 4px; height: 4px; }.gm-style-iw{ overflow: hidden !important; }",t=" .travelmap-overlay{ display:block; text-align:center; color:#fff; font-size:12px; line-height:14px; opacity:0.8; background:#4477aa; border:solid 3px #336699; border-radius:4px; box-shadow:2px 2px 10px #333; text-shadow:1px 1px 1px #666; padding:0 4px; margin-top: -24px; white-space: nowrap;}.travelmap-overlay-arrow{ left:50%; margin-left:-16px; width:0; height:0; position:absolute;}.travelmap-overlay-arrow.travelmap-overlay-arrow-above{ bottom:-15px; border-left:16px solid transparent; border-right:16px solid transparent; border-top:16px solid #336699;}.travelmap-overlay-arrow.travelmap-overlay-arrow-below{ top:-15px; border-left:16px solid transparent; border-right:16px solid transparent; border-bottom:16px solid #336699;}",e=document.createElement("style");e.innerHTML=o+t,document.head.appendChild(e)},n=function(o,t){var e=t;for(var r in o)o.hasOwnProperty(r)&&void 0!==o[r]&&(e[r]=o[r]);return e};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=o),exports.travelMap=o):this.travelMap=o,"function"==typeof define&&define.amd&&define("travelMap",[],function(){return o})}).call(this);
//# sourceMappingURL=travelmap.js.map