UNPKG

neshan-map

Version:

### Developed by [Neshan Maps Platform team](https://platform.neshan.org). ### For Farsi/Persian document, [click here](https://developers.neshan.org/react-component/).

3 lines (2 loc) 1.58 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function r(){return(r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var o="https://static.neshan.org/sdk/leaflet/1.4.0/leaflet.css";exports.default=function(e){var a=e.style,s=e.options,c=e.onInit,i=t.useRef(null),d={key:"YOUR_API_KEY",maptype:"dreamy",poi:!0,traffic:!1,center:[35.699739,51.338097],zoom:14};return t.useEffect((function(){!function(e){!function(){var t=e.onError,n=e.onLoad;if(!document.head.querySelector('link[href="'+o+'"]')){var r=document.createElement("link");r.href=o,r.rel="stylesheet",document.head.appendChild(r)}if(window.L)n&&n();else{var a=document.body.querySelector('script[src="https://static.neshan.org/sdk/leaflet/1.4.0/leaflet.js"]')||document.createElement("script");a.addEventListener("load",(function(){n&&n()})),a.addEventListener("error",(function(){t&&t()})),a.src||(a.src="https://static.neshan.org/sdk/leaflet/1.4.0/leaflet.js",document.body.appendChild(a))}}()}({onLoad:function(){var e=new window.L.Map(i.current,r({},d,s));c&&c(window.L,e)},onError:function(){console.error("Neshan Maps Error: This page didn't load Neshan Maps correctly")}})}),[]),n.createElement("div",{ref:i,style:r({},{width:"600px",height:"450px",margin:0,padding:0,background:"#eee"},a)})}; //# sourceMappingURL=neshan-map.cjs.production.min.js.map