Commit 335b40ce1f545ff3bc9c1aa2bd67c59ebc1050aa
- Diff rendering mode:
- inline
- side by side
mouchak/static/js/leaflet.js
(105 / 0)
  | |||
2279 | 2279 | }}); | |
2280 | 2280 | }; | |
2281 | 2281 | })(window.CRP); | |
2282 | |||
2283 | /* | ||
2284 | Leaflet.AwesomeMarkers, a plugin that adds colorful iconic markers for Leaflet, based on the Font Awesome icons | ||
2285 | (c) 2012-2013, Lennard Voogdt | ||
2286 | |||
2287 | http://leafletjs.com | ||
2288 | https://github.com/lvoogdt | ||
2289 | */ | ||
2290 | (function (window, document, undefined) { | ||
2291 | /* | ||
2292 | * Leaflet.AwesomeMarkers assumes that you have already included the Leaflet library. | ||
2293 | */ | ||
2294 | |||
2295 | L.AwesomeMarkers = {}; | ||
2296 | |||
2297 | L.AwesomeMarkers.version = '1.0'; | ||
2298 | |||
2299 | L.AwesomeMarkers.Icon = L.Icon.extend({ | ||
2300 | options: { | ||
2301 | iconSize: [35, 45], | ||
2302 | iconAnchor: [17, 42], | ||
2303 | popupAnchor: [1, -32], | ||
2304 | shadowAnchor: [10, 12], | ||
2305 | shadowSize: [36, 16], | ||
2306 | className: 'awesome-marker', | ||
2307 | icon: 'home', | ||
2308 | color: 'blue', | ||
2309 | iconColor: 'white' | ||
2310 | }, | ||
2311 | |||
2312 | initialize: function (options) { | ||
2313 | options = L.setOptions(this, options); | ||
2314 | }, | ||
2315 | |||
2316 | createIcon: function () { | ||
2317 | var div = document.createElement('div'), | ||
2318 | options = this.options; | ||
2319 | |||
2320 | if (options.icon) { | ||
2321 | div.innerHTML = this._createInner(); | ||
2322 | } | ||
2323 | |||
2324 | if (options.bgPos) { | ||
2325 | div.style.backgroundPosition = | ||
2326 | (-options.bgPos.x) + 'px ' + (-options.bgPos.y) + 'px'; | ||
2327 | } | ||
2328 | |||
2329 | this._setIconStyles(div, 'icon-' + options.color); | ||
2330 | return div; | ||
2331 | }, | ||
2332 | |||
2333 | _createInner: function() { | ||
2334 | var iconClass; | ||
2335 | if(this.options.icon.slice(0,5)==="icon-"){ | ||
2336 | iconClass=this.options.icon; | ||
2337 | }else{ | ||
2338 | iconClass="icon-"+this.options.icon; | ||
2339 | } | ||
2340 | return "<i class='" + iconClass | ||
2341 | + (this.options.spin ? " icon-spin" :"") | ||
2342 | + (this.options.iconColor ? " icon-" + this.options.iconColor :"") + "'></i>"; | ||
2343 | }, | ||
2344 | |||
2345 | _setIconStyles: function (img, name) { | ||
2346 | var options = this.options, | ||
2347 | size = L.point(options[name == 'shadow' ? 'shadowSize' : 'iconSize']), | ||
2348 | anchor; | ||
2349 | |||
2350 | if (name === 'shadow') { | ||
2351 | anchor = L.point(options.shadowAnchor || options.iconAnchor); | ||
2352 | } else { | ||
2353 | anchor = L.point(options.iconAnchor); | ||
2354 | } | ||
2355 | |||
2356 | if (!anchor && size) { | ||
2357 | anchor = size.divideBy(2, true); | ||
2358 | } | ||
2359 | |||
2360 | img.className = 'awesome-marker-' + name + ' ' + options.className; | ||
2361 | |||
2362 | if (anchor) { | ||
2363 | img.style.marginLeft = (-anchor.x) + 'px'; | ||
2364 | img.style.marginTop = (-anchor.y) + 'px'; | ||
2365 | } | ||
2366 | |||
2367 | if (size) { | ||
2368 | img.style.width = size.x + 'px'; | ||
2369 | img.style.height = size.y + 'px'; | ||
2370 | } | ||
2371 | }, | ||
2372 | |||
2373 | createShadow: function () { | ||
2374 | var div = document.createElement('div'), | ||
2375 | options = this.options; | ||
2376 | |||
2377 | this._setIconStyles(div, 'shadow'); | ||
2378 | return div; | ||
2379 | } | ||
2380 | }); | ||
2381 | |||
2382 | L.AwesomeMarkers.icon = function (options) { | ||
2383 | return new L.AwesomeMarkers.Icon(options); | ||
2384 | }; | ||
2385 | |||
2386 | }(this, document)); |