yourcelf / olwidget

Javascript library to replace textareas that contain WKT data with editable OpenLayers maps, and a django app using it for django forms and admin.
Other
91 stars 44 forks source link

can't construct a map with empty opts.layers #72

Closed slinkp closed 13 years ago

slinkp commented 13 years ago

If opts.layers == [], you get an error in map construction. This is problematic if you don't want to use any of the provided base layers, eg. you want to instead later call addLayer() and initCenter() yourself.

Fortunately there's a two-line fix for this, just don't call initCenter unless we got opts.layers:

--- a/js/olwidget.js +++ b/js/olwidget.js @@ -279,7 +279,11 @@ olwidget.Map = OpenLayers.Class(OpenLayers.Map, { } if (layers.length > 0) { this.addLayers(layers);

yourcelf commented 13 years ago

Thanks, fixed this by instead checking for if (this.baseLayer), so that it's not tied to the options implementation. If that fails to work please open a new issue.