PageSourceSearch

https://longpaddock.qld.gov.au/vendor/other/leaflet.defaultextent.js

js longpaddock.qld.gov.au collected 2026-09-24 17:34:24 UTC 2,872 bytes, 87 lines download raw bytes

1(function(root, factory) {
2    if (typeof define === 'function' && define.amd) {
3        define(["leaflet"], factory);
4    } else if (typeof exports === 'object') {
5        module.exports = factory(require('leaflet'));
6    } else {
7        root.L.Control.DefaultExtent = factory(root.L);
8    }
9}(this, function(L) {
10
11    return (function() {
12        /* global L */
13        'use strict';
14        L.Control.DefaultExtent = L.Control.extend({
15            options: {
16                position: 'topleft',
17                text: '<i class="fad fa-home"></i>',
18                title: 'Zoom to default extent',
19                className: 'leaflet-control-defaultextent'
20            },
21            onAdd: function(map) {
22                this._map = map;
23                return this._initLayout();
24            },
25            setCenter: function(center) {
26                this._center = center;
27                return this;
28            },
29            setZoom: function(zoom) {
30                this._zoom = zoom;
31                return this;
32            },
33            _initLayout: function() {
34                var container = L.DomUtil.create('div', 'leaflet-bar ' +
35                    this.options.className);
36                this._container = container;
37                this.FullExtentButton = this._createExtentButton(container);
38
39                L.DomEvent.disableClickPropagation(container);
40
41                this._map.whenReady(this._whenReady, this);
42
43                return this._container;
44            },
45            _createExtentButton: function() {
46                var link = L.DomUtil.create('a', this.options.className + '-toggle',
47                    this._container);
48                link.href = '#';
49                link.innerHTML = this.options.text;
50                link.title = this.options.title;
51
52                L.DomEvent
53                    .on(link, 'mousedown dblclick', L.DomEvent.stopPropagation)
54                    .on(link, 'click', L.DomEvent.stop)
55                    .on(link, 'click', this.ZoomToDefault, this);
56                return link;
57            },
58            _whenReady: function() {
59                if (!this._center) {
60                    this._center = this._map.getCenter();
61                }
62                if (!this._zoom) {
63                    this._zoom = this._map.getZoom();
64                }
65                return this;
66            },
67            ZoomToDefault: function() {
68                this._map.setView(this._center, this._zoom);
69            }
70        });
71
72        L.Map.addInitHook(function() {
73            if (this.options.defaultExtentControl) {
74                this.addControl(new L.Control.DefaultExtent());
75            }
76        });
77
78        L.control.defaultExtent = function(options) {
79            return new L.Control.DefaultExtent(options);
80        };
81
82        return L.Control.DefaultExtent;
83
84    }());
85
86
87}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.