MCPcopy Create free account
hub / github.com/c3bottles/c3bottles / initializeMap

Function initializeMap

js/common/map.js:149–294  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

147};
148
149function initializeMap() {
150 if (mapSource.hack_257px) {
151 const originalInitTile = L.GridLayer.prototype._initTile;
152
153 L.GridLayer.include({
154 _initTile(tile) {
155 originalInitTile.call(this, tile);
156 const tileSize = this.getTileSize();
157
158 tile.style.width = `${tileSize.x + 1}px`;
159 tile.style.height = `${tileSize.y + 1}px`;
160 },
161 });
162 }
163
164 const map_options = {
165 attributionControl: true,
166 minZoom: mapSource.min_zoom,
167 maxZoom: mapSource.max_zoom,
168 maxBounds: mapSource.bounds ? L.GeoJSON.coordsToLatLngs(mapSource.bounds) : undefined,
169 };
170
171 if (mapSource.simple_crs) {
172 map_options.crs = L.CRS.Simple;
173 }
174
175 mapObj = L.map('map', map_options);
176
177 if (mapSource.level_config) {
178 // from c3nav: site/static/site/js/c3nav.js
179 const LayerControlWidget = L.Control.extend({
180 options: {
181 position: 'bottomright',
182 addClasses: '',
183 },
184
185 onAdd() {
186 this._container = L.DomUtil.create('div', `leaflet-control-levels leaflet-bar ${this.options.addClasses}`);
187 this._tileLayers = {};
188 this._overlayLayers = {};
189 this._levelButtons = {};
190 this.currentLevel = null;
191
192 return this._container;
193 },
194
195 addLayer(id, title) {
196 this._tileLayers[id] = L.tileLayer(`${mapSource.tileserver + String(id)}/{z}/{x}/{y}.png`, {
197 minZoom: mapSource.min_zoom,
198 maxZoom: mapSource.max_zoom,
199 bounds: mapSource.bounds ? L.GeoJSON.coordsToLatLngs(mapSource.bounds) : undefined,
200 attribution: mapSource.attribution,
201 subdomains: mapSource.tileserver_subdomains,
202 });
203 const overlay = L.layerGroup();
204
205 this._overlayLayers[id] = overlay;
206

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected