diff --git a/dist/mapbox-gl-scale.js b/dist/mapbox-gl-scale.js index 4c63506..80a31c3 100644 --- a/dist/mapbox-gl-scale.js +++ b/dist/mapbox-gl-scale.js @@ -1 +1,114 @@ -!function t(n,o,r){function e(a,c){if(!o[a]){if(!n[a]){var l="function"==typeof require&&require;if(!c&&l)return l(a,!0);if(i)return i(a,!0);var p=new Error("Cannot find module '"+a+"'");throw p.code="MODULE_NOT_FOUND",p}var s=o[a]={exports:{}};n[a][0].call(s.exports,function(t){var o=n[a][1][t];return e(o?o:t)},s,s.exports,t,n,o,r)}return o[a].exports}for(var i="function"==typeof require&&require,a=0;ar?r+" m":r/1e3+" km"}function i(t,n){var o=6371e3,r=Math.PI/180,e=t.lat*r,i=n.lat*r,a=Math.sin(e)*Math.sin(i)+Math.cos(e)*Math.cos(i)*Math.cos((n.lng-t.lng)*r),c=o*Math.acos(Math.min(a,1));return c}function a(t){var n=Math.pow(10,(Math.floor(t)+"").length-1),o=t/n;return o=o>=10?10:o>=5?5:o>=3?3:o>=2?2:1,n*o}if(!mapboxgl)throw new Error("include mapboxgl before mapbox-gl-scale.js");var c=t("xtend");r.prototype=mapboxgl.util.inherit(mapboxgl.Control,{options:{position:"top-right",zoom:16,flyTo:!0},onAdd:function(t){this.container=this.options.container?"string"==typeof this.options.container?document.getElementById(this.options.container):this.options.container:t.getContainer();var n=document.createElement("div");n.className="mapboxgl-ctrl-scale",n.id="ruler",this.container.appendChild(n),e(t),t.on("moveend",function(){e(t)})}}),window.mapboxgl?mapboxgl.Scale=r:"undefined"!=typeof n&&(n.exports=r)},{xtend:2}],2:[function(t,n,o){function r(){for(var t={},n=0;n= 10 ? 10 : + d >= 5 ? 5 : + d >= 3 ? 3 : + d >= 2 ? 2 : 1; + + return pow10 * d; +} + +if (window.mapboxgl) { + mapboxgl.Scale = Scale; +} else if (typeof module !== 'undefined') { + module.exports = Scale; +} + +},{"xtend":2}],2:[function(require,module,exports){ +module.exports = extend + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +function extend() { + var target = {} + + for (var i = 0; i < arguments.length; i++) { + var source = arguments[i] + + for (var key in source) { + if (hasOwnProperty.call(source, key)) { + target[key] = source[key] + } + } + } + + return target +} + +},{}]},{},[1]); diff --git a/index.js b/index.js index 4dd4a44..a070a5d 100644 --- a/index.js +++ b/index.js @@ -36,6 +36,7 @@ Scale.prototype = mapboxgl.util.inherit(mapboxgl.Control, { _updateScale(map); }); + return el; }, }); @@ -86,4 +87,4 @@ if (window.mapboxgl) { mapboxgl.Scale = Scale; } else if (typeof module !== 'undefined') { module.exports = Scale; -} \ No newline at end of file +}