Skip to content

Commit

Permalink
Fixed #25004 -- Updated OpenLayers-based widget to OpenLayers 3
Browse files Browse the repository at this point in the history
Thanks Tim Graham for the review.
  • Loading branch information
claudep committed Jan 2, 2017
1 parent f996f73 commit 2ebfda3
Show file tree
Hide file tree
Showing 16 changed files with 295 additions and 384 deletions.
19 changes: 11 additions & 8 deletions django/contrib/gis/forms/widgets.py
Expand Up @@ -80,13 +80,22 @@ class OpenLayersWidget(BaseGeometryWidget):
template_name = 'gis/openlayers.html'

class Media:
css = {
'all': (
'https://cdnjs.cloudflare.com/ajax/libs/ol3/3.20.1/ol.css',
'gis/css/ol3.css',
)
}
js = (
'https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js',
'https://cdnjs.cloudflare.com/ajax/libs/ol3/3.20.1/ol.js',
'gis/js/OLMapWidget.js',
)

def serialize(self, value):
return value.json if value else ''


class OSMWidget(BaseGeometryWidget):
class OSMWidget(OpenLayersWidget):
"""
An OpenLayers/OpenStreetMap-based widget.
"""
Expand All @@ -95,12 +104,6 @@ class OSMWidget(BaseGeometryWidget):
default_lat = 47
map_srid = 3857

class Media:
js = (
'https://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js',
'gis/js/OLMapWidget.js',
)

def __init__(self, attrs=None):
super(OSMWidget, self).__init__()
for key in ('default_lon', 'default_lat'):
Expand Down
31 changes: 31 additions & 0 deletions django/contrib/gis/static/gis/css/ol3.css
@@ -0,0 +1,31 @@
.switch-type {
background-repeat: no-repeat;
cursor: pointer;
top: 0.5em;
width: 22px;
height: 20px;
}

.type-Point {
background-image: url("../img/draw_point_off.png");
right: 5px;
}
.type-Point.type-active {
background-image: url("../img/draw_point_on.png");
}

.type-LineString {
background-image: url("../img/draw_line_off.png");
right: 30px;
}
.type-LineString.type-active {
background-image: url("../img/draw_line_on.png");
}

.type-Polygon {
background-image: url("../img/draw_polygon_off.png");
right: 55px;
}
.type-Polygon.type-active {
background-image: url("../img/draw_polygon_on.png");
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2ebfda3

Please sign in to comment.