mirror of
				https://github.com/django/django.git
				synced 2025-10-31 01:25:32 +00:00 
			
		
		
		
	Upgraded OpenLayers to v.7.2.2.
This commit is contained in:
		| @@ -102,12 +102,12 @@ class OpenLayersWidget(BaseGeometryWidget): | ||||
|     class Media: | ||||
|         css = { | ||||
|             "all": ( | ||||
|                 "https://cdnjs.cloudflare.com/ajax/libs/ol3/4.6.5/ol.css", | ||||
|                 "https://cdn.jsdelivr.net/npm/ol@v7.2.2/ol.css", | ||||
|                 "gis/css/ol3.css", | ||||
|             ) | ||||
|         } | ||||
|         js = ( | ||||
|             "https://cdnjs.cloudflare.com/ajax/libs/ol3/4.6.5/ol.js", | ||||
|             "https://cdn.jsdelivr.net/npm/ol@v7.2.2/dist/ol.js", | ||||
|             "gis/js/OLMapWidget.js", | ||||
|         ) | ||||
|  | ||||
|   | ||||
| @@ -1,39 +1,40 @@ | ||||
| /* global ol */ | ||||
| 'use strict'; | ||||
| function GeometryTypeControl(opt_options) { | ||||
| class GeometryTypeControl extends ol.control.Control { | ||||
|     // Map control to switch type when geometry type is unknown | ||||
|     const options = opt_options || {}; | ||||
|     constructor(opt_options) { | ||||
|         const options = opt_options || {}; | ||||
|  | ||||
|     const element = document.createElement('div'); | ||||
|     element.className = 'switch-type type-' + options.type + ' ol-control ol-unselectable'; | ||||
|     if (options.active) { | ||||
|         element.classList.add("type-active"); | ||||
|     } | ||||
|  | ||||
|     const self = this; | ||||
|     const switchType = function(e) { | ||||
|         e.preventDefault(); | ||||
|         if (options.widget.currentGeometryType !== self) { | ||||
|             options.widget.map.removeInteraction(options.widget.interactions.draw); | ||||
|             options.widget.interactions.draw = new ol.interaction.Draw({ | ||||
|                 features: options.widget.featureCollection, | ||||
|                 type: options.type | ||||
|             }); | ||||
|             options.widget.map.addInteraction(options.widget.interactions.draw); | ||||
|             options.widget.currentGeometryType.element.classList.remove('type-active'); | ||||
|             options.widget.currentGeometryType = self; | ||||
|         const element = document.createElement('div'); | ||||
|         element.className = 'switch-type type-' + options.type + ' ol-control ol-unselectable'; | ||||
|         if (options.active) { | ||||
|             element.classList.add("type-active"); | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|     element.addEventListener('click', switchType, false); | ||||
|     element.addEventListener('touchstart', switchType, false); | ||||
|         super({ | ||||
|             element: element, | ||||
|             target: options.target | ||||
|         }); | ||||
|         const self = this; | ||||
|         const switchType = function(e) { | ||||
|             e.preventDefault(); | ||||
|             if (options.widget.currentGeometryType !== self) { | ||||
|                 options.widget.map.removeInteraction(options.widget.interactions.draw); | ||||
|                 options.widget.interactions.draw = new ol.interaction.Draw({ | ||||
|                     features: options.widget.featureCollection, | ||||
|                     type: options.type | ||||
|                 }); | ||||
|                 options.widget.map.addInteraction(options.widget.interactions.draw); | ||||
|                 options.widget.currentGeometryType.element.classList.remove('type-active'); | ||||
|                 options.widget.currentGeometryType = self; | ||||
|                 element.classList.add("type-active"); | ||||
|             } | ||||
|         }; | ||||
|  | ||||
|     ol.control.Control.call(this, { | ||||
|         element: element | ||||
|     }); | ||||
| }; | ||||
| ol.inherits(GeometryTypeControl, ol.control.Control); | ||||
|         element.addEventListener('click', switchType, false); | ||||
|         element.addEventListener('touchstart', switchType, false); | ||||
|     } | ||||
| } | ||||
|  | ||||
| // TODO: allow deleting individual features (#8972) | ||||
| class MapWidget { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user