Opened 10 years ago

Last modified 10 years ago

#23137 closed Bug

Error when use OSMapWidget.js — at Version 1

Reported by: koyoyo Owned by: nobody
Component: GIS Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

I try to create my form with GeoDjango and I didn't found an good example in document.

So, I use django/contrib/gis/static/gis/js/OSMapWidget.js and found that have some of bugs.

First, in line 173 (miss .) eg. if geom_name = 'MultiPoint', then options['geom_type'] will be OpenLayers.GeometryMultiPoint

else options['geom_type'] = eval('OpenLayers.Geometry' + options['geom_name']);

changed to

else options['geom_type'] = eval('OpenLayers.Geometry.' + options['geom_name']);

Second, line 181 (check is_collection) It is wrong use of function "isinstanceof". It cannot check constructor isinstanceof constructor.

is_collection: options['geom_name'] instanceof OpenLayers.Geometry.Collection,

changed to

is_collection: (options['geom_name'].substr(0, 5) == 'Multi' || options[ 'geom_type' ] == 'GeometryCollection'),

Third, in function getControls (line 366, 369, 372) These are not check for Collection.

if (this.options.geom_name == 'LineString'' || this.options.geom_name == 'Unknown') {
if (this.options.geom_name == 'Polygon'  || this.options.geom_name == 'Unknown') {
if (this.options.geom_name == 'Point'  || this.options.geom_name == 'Unknown') {

changed to

if (this.options.geom_name == 'LineString' || this.options.geom_name == 'MultiLineString' || this.options.geom_name == 'Unknown') {
if (this.options.geom_name == 'Polygon' || this.options.geom_name == 'MultiPolygon' || this.options.geom_name == 'Unknown') {
if (this.options.geom_name == 'Point' || this.options.geom_name == 'MultiPoint' || this.options.geom_name == 'Unknown') {

Change History (1)

comment:1 by Tim Graham, 10 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top