mirror of
https://github.com/RustyRaptor/react-leaflet-google.git
synced 2026-12-03 23:45:17 -07:00
1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("react-leaflet")):"function"==typeof define&&define.amd?define(["react","react-leaflet"],e):"object"==typeof exports?exports.ReactLeaflet=e(require("react"),require("react-leaflet")):t.ReactLeaflet=e(t.React,t[void 0])}(this,function(t,e){return function(t){function e(n){if(i[n])return i[n].exports;var o=i[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}([function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.GoogleLayer=void 0;var o=i(1),r=n(o);e.GoogleLayer=r.default},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function o(t,e){var i={};for(var n in t)e.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=t[n]);return i}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var l=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),u=function t(e,i,n){null===e&&(e=Function.prototype);var o=Object.getOwnPropertyDescriptor(e,i);if(void 0===o){var r=Object.getPrototypeOf(e);return null===r?void 0:t(r,i,n)}if("value"in o)return o.value;var a=o.get;if(void 0!==a)return a.call(n)},h=i(4),p=(n(h),i(5)),c=(i(2),function(t){function e(){return r(this,e),a(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return s(e,t),l(e,[{key:"componentWillMount",value:function(){u(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"componentWillMount",this).call(this);var t=this.props;t.map,t.googlekey,t.maptype,t.asclientid,o(t,["map","googlekey","maptype","asclientid"]);this.leafletElement=new L.gridLayer.googleMutant(this.props)}},{key:"componentDidUpdate",value:function(t){var e=this.props,i=e.opacity,n=e.zIndex;i!==t.opacity&&this.leafletElement.setOpacity(i),n!==t.zIndex&&this.leafletElement.setZIndex(n)}}]),e}(p.GridLayer));c.propTypes={googlekey:h.PropTypes.string.isRequired,maptype:h.PropTypes.string,asclientid:h.PropTypes.bool},e.default=c},function(t,e,i){"use strict";var n=i(3);n.VERSION="3.18",L.GridLayer.GoogleMutant=L.GridLayer.extend({includes:L.Mixin.Events,options:{minZoom:0,maxZoom:18,tileSize:256,subdomains:"abc",errorTileUrl:"",attribution:"",opacity:1,continuousWorld:!1,noWrap:!1,type:"satellite",maxNativeZoom:21},initialize:function(t){L.GridLayer.prototype.initialize.call(this,t);var e=this;t.asclientid?n.CLIENT=t.googlekey:n.KEY=t.googlekey,n.LIBRARIES=t.libraries||[],e._type=t.maptype||"SATELLITE",n.load(function(i){google=i,console.log("I just loaded google maps api"),e._ready=!0,e._initMutant(),e._update(),t.onAfterLoad&&t.onAfterLoad(google)}),this._tileCallbacks={},this._freshTiles={},this._imagesPerTile="hybrid"===e._type?2:1,this.createTile="hybrid"===e._type?this._createMultiTile:this._createSingleTile},onAdd:function(t){L.GridLayer.prototype.onAdd.call(this,t),this._initMutantContainer(),this._ready&&(this._map=t,this._initMutant(),t.on("viewreset",this._reset,this),t.on("move",this._update,this),t.on("zoomend",this._handleZoomAnim,this),t.on("resize",this._resize,this),t._controlCorners.bottomright.style.marginBottom="20px",this._reset(),this._update())},onRemove:function(t){L.GridLayer.prototype.onRemove.call(this,t),t._container.removeChild(this._mutantContainer),this._mutantContainer=void 0,t.off("viewreset",this._reset,this),t.off("move",this._update,this),t.off("zoomend",this._handleZoomAnim,this),t.off("resize",this._resize,this),t._controlCorners.bottomright.style.marginBottom="0em"},getAttribution:function(){return this.options.attribution},setOpacity:function(t){this.options.opacity=t,t<1&&L.DomUtil.setOpacity(this._mutantContainer,t)},setElementSize:function(t,e){t.style.width=e.x+"px",t.style.height=e.y+"px"},_initMutantContainer:function(){this._mutantContainer||(this._mutantContainer=L.DomUtil.create("div","leaflet-google-mutant leaflet-top leaflet-left"),this._mutantContainer.id="_MutantContainer_"+L.Util.stamp(this._mutantContainer),this._mutantContainer.style.pointerEvents="none",this._map.getContainer().appendChild(this._mutantContainer)),this.setOpacity(this.options.opacity),this.setElementSize(this._mutantContainer,this._map.getSize()),this._attachObserver(this._mutantContainer)},_initMutant:function(){if(this._ready&&this._mutantContainer){this._mutantCenter=new google.maps.LatLng(0,0);var t=new google.maps.Map(this._mutantContainer,{center:this._mutantCenter,zoom:0,tilt:0,mapTypeId:google.maps.MapTypeId[this._type],disableDefaultUI:!0,keyboardShortcuts:!1,draggable:!1,disableDoubleClickZoom:!0,scrollwheel:!1,streetViewControl:!1,styles:this.options.styles||{},backgroundColor:"transparent"});this._mutant=t,this.fire("spawned",{mapObject:t})}},_attachObserver:function(t){var e=new MutationObserver(this._onMutations.bind(this));e.observe(t,{childList:!0,subtree:!0})},_onMutations:function(t){for(var e=0;e<t.length;++e)for(var i=t[e],n=0;n<i.addedNodes.length;++n){var o=i.addedNodes[n];o instanceof HTMLImageElement?this._onMutatedImage(o):o instanceof HTMLElement&&Array.prototype.forEach.call(o.querySelectorAll("img"),this._onMutatedImage.bind(this))}},_roadRegexp:/!1i(\d+)!2i(\d+)!3i(\d+)!/,_satRegexp:/x=(\d+)&y=(\d+)&z=(\d+)/,_staticRegExp:/StaticMapService\.GetMapImage/,_onMutatedImage:function(t){var e,i,n,o=t.src.match(this._roadRegexp);if(o?(e={z:o[1],x:o[2],y:o[3]},this._imagesPerTile>1&&(t.style.zIndex=1),i=1):(o=t.src.match(this._satRegexp),o&&(e={x:o[1],y:o[2],z:o[3]}),i=0),e){var r=this._tileCoordsToKey(e);t.style.position="absolute",this._imagesPerTile>1&&(r+="/"+i),r in this._tileCallbacks&&this._tileCallbacks[r]?(this._tileCallbacks[r].pop()(t),this._tileCallbacks[r].length||delete this._tileCallbacks[r]):(n=t.parentNode,n&&(n.removeChild(t),n.removeChild=L.Util.falseFn),r in this._freshTiles?this._freshTiles[r].push(t):this._freshTiles[r]=[t])}else t.src.match(this._staticRegExp)&&(n=t.parentNode,n&&t.parentNode.replaceChild(L.DomUtil.create("img"),t))},_createSingleTile:function(t,e){var i=this._tileCoordsToKey(t);if(i in this._freshTiles){var n=this._freshTiles[i].pop();return this._freshTiles[i].length||delete this._freshTiles[i],L.Util.requestAnimFrame(e),n}var o=L.DomUtil.create("div");return this._tileCallbacks[i]=this._tileCallbacks[i]||[],this._tileCallbacks[i].push(function(t){return function(i){var n=i.parentNode;n&&(n.removeChild(i),n.removeChild=L.Util.falseFn),t.appendChild(i),e()}.bind(this)}.bind(this)(o)),o},_createMultiTile:function(t,e){var i=this._tileCoordsToKey(t),n=L.DomUtil.create("div");n.dataset.pending=this._imagesPerTile;for(var o=0;o<this._imagesPerTile;o++){var r=i+"/"+o;r in this._freshTiles?(n.appendChild(this._freshTiles[r].pop()),this._freshTiles[r].length||delete this._freshTiles[r],n.dataset.pending--):(this._tileCallbacks[r]=this._tileCallbacks[r]||[],this._tileCallbacks[r].push(function(t){return function(i){var n=i.parentNode;n&&(n.removeChild(i),n.removeChild=L.Util.falseFn),t.appendChild(i),t.dataset.pending--,parseInt(t.dataset.pending)||e()}.bind(this)}.bind(this)(n)))}return parseInt(n.dataset.pending)||L.Util.requestAnimFrame(e),n},_checkZoomLevels:function(){void 0!==this._map.getZoom()&&this._mutant.getZoom()!==this._map.getZoom()&&this._map.setZoom(this._mutant.getZoom())},_reset:function(){this._initContainer()},_update:function(){if(L.GridLayer.prototype._update.call(this),this._mutant){var t=this._map.getCenter(),e=new google.maps.LatLng(t.lat,t.lng);this._mutant.setCenter(e);var i=this._map.getZoom();void 0!==i&&this._mutant.setZoom(Math.round(this._map.getZoom()))}},_resize:function(){var t=this._map.getSize();this._mutantContainer.style.width===t.x&&this._mutantContainer.style.height===t.y||(this.setElementSize(this._mutantContainer,t),this._mutant&&google.maps.event.trigger(this._mutant,"resize"))},_handleZoomAnim:function(){var t=this._map.getCenter(),e=new google.maps.LatLng(t.lat,t.lng);this._mutant.setCenter(e),this._mutant.setZoom(Math.round(this._map.getZoom()))},_removeTile:function(t){if(this._imagesPerTile>1)for(var e=0;e<this._imagesPerTile;e++){var i=t+"/"+e;i in this._freshTiles&&delete this._freshTiles[i]}else t in this._freshTiles&&delete this._freshTiles[t];return L.GridLayer.prototype._removeTile.call(this,t)}}),L.gridLayer.googleMutant=function(t){return new L.GridLayer.GoogleMutant(t)}},function(t,e,i){var n,o;!function(r,a){if(null===r)throw new Error("Google-maps package can be used only in browser");n=a,o="function"==typeof n?n.call(e,i,e,t):n,!(void 0!==o&&(t.exports=o))}("undefined"!=typeof window?window:null,function(){"use strict";var t="3.18",e=null,i=null,n=!1,o=[],r=[],a=null,s={};s.URL="https://maps.googleapis.com/maps/api/js",s.KEY=null,s.LIBRARIES=[],s.CLIENT=null,s.CHANNEL=null,s.LANGUAGE=null,s.REGION=null,s.VERSION=t,s.WINDOW_CALLBACK_NAME="__google_maps_api_provider_initializator__",s._googleMockApiObject={},s.load=function(t){null===i?n===!0?t&&o.push(t):(n=!0,window[s.WINDOW_CALLBACK_NAME]=function(){l(t)},s.createLoader()):t&&t(i)},s.createLoader=function(){e=document.createElement("script"),e.type="text/javascript",e.src=s.createUrl(),document.body.appendChild(e)},s.isLoaded=function(){return null!==i},s.createUrl=function(){var t=s.URL;return t+="?callback="+s.WINDOW_CALLBACK_NAME,s.KEY&&(t+="&key="+s.KEY),s.LIBRARIES.length>0&&(t+="&libraries="+s.LIBRARIES.join(",")),s.CLIENT&&(t+="&client="+s.CLIENT+"&v="+s.VERSION),s.CHANNEL&&(t+="&channel="+s.CHANNEL),s.LANGUAGE&&(t+="&language="+s.LANGUAGE),s.REGION&&(t+="®ion="+s.REGION),t},s.release=function(l){var u=function(){s.KEY=null,s.LIBRARIES=[],s.CLIENT=null,s.CHANNEL=null,s.LANGUAGE=null,s.REGION=null,s.VERSION=t,i=null,n=!1,o=[],r=[],"undefined"!=typeof window.google&&delete window.google,"undefined"!=typeof window[s.WINDOW_CALLBACK_NAME]&&delete window[s.WINDOW_CALLBACK_NAME],null!==a&&(s.createLoader=a,a=null),null!==e&&(e.parentElement.removeChild(e),e=null),l&&l()};n?s.load(function(){u()}):u()},s.onLoad=function(t){r.push(t)},s.makeMock=function(){a=s.createLoader,s.createLoader=function(){window.google=s._googleMockApiObject,window[s.WINDOW_CALLBACK_NAME]()}};var l=function(t){var e;for(n=!1,null===i&&(i=window.google),e=0;e<r.length;e++)r[e](i);for(t&&t(i),e=0;e<o.length;e++)o[e](i);o=[]};return s})},function(e,i){e.exports=t},function(t,i){t.exports=e}])}); |