forked from devlint/osmLeaflet.jQuery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
osmLeaflet.jquery.min.js
11 lines (11 loc) · 1.93 KB
/
osmLeaflet.jquery.min.js
1
2
3
4
5
6
7
8
9
10
11
/**
* osmLeaflet.jQuery, minified version
* jQuery plugin, wrapper for the Leaflet API
* Need Leaflet 0.6+
*
* @author Mathieu ROBIN
* @link http://www.mathieurobin.com/osmLeaflet
* @copyright MIT License
* @version 1.2
*/
(function(e){var t={zoom:10,maxZoom:18,latitude:0,longitude:0,cloudmadeAttribution:'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery \u00a9 <a href="http://cloudmade.com">CloudMade</a>, osmLeaflet.jQuery by Mathieu ROBIN'},n,r,i={init:function(i){var s=this;return this.each(function(){i&&(n=e.extend(t,i)),r=L.map(this.id).setView([n.latitude,n.longitude],n.zoom),L.tileLayer("http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/{styleId}/256/{z}/{x}/{y}.png",{attribution:t.cloudmadeAttribution,styleId:997}).addTo(r),L.control.scale().addTo(r),"undefined"!=typeof i.click&&"function"==typeof i.click&&r.on("click",i.click),"undefined"!=typeof i.markers&&s.osmLeaflet("addMarker",i.markers),"undefined"!=typeof i.popup&&s.osmLeaflet("addPopup",i.popup)})},addMarker:function(e){var t=this;return this.each(function(){var n=null,i=null;if("undefined"!=typeof e)if("undefined"==typeof e.length)n=L.marker([e.latitude,e.longitude]).addTo(r),"undefined"!=typeof e.click&&n.bindPopup(e.click);else for(n in e)t.osmLeaflet("addMarker",e[n])})},addPopup:function(e){return this.each(function(){if("undefined"!=typeof e)var t=(new L.Popup).setLatLng(new L.LatLng(e.latitude,e.longitude)).setContent(e.content).openOn(r)})},onClick:function(e){return this.each(function(){"undefined"!=typeof e&&("function"==typeof e?r.on("click",e):"Deferred"==typeof e&&r.on("click",function(){e.resolve()}))})}};e.fn.osmLeaflet=function(t){if(i[t])return i[t].apply(this,Array.prototype.slice.call(arguments,1));if(typeof t=="object"||!t)return i.init.apply(this,arguments);e.error("Method "+t+" does not exist on jQuery.osmLeaflet")}})(jQuery);