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 43 forks source link

Multiple named Vector Layers would be awesome #34

Closed skyl closed 13 years ago

skyl commented 14 years ago

Right now, InfoMap is pretty hard-coded to take a single array that is, by default, name "data". It would be awesome if you could pass a dict:

{"layer1": [[],[],[]], "layer2":[[],[],[]...], ...}

And get multiple different vector layers that could be turned on and off.

yourcelf commented 14 years ago

Yeah, would be awesome. And a lot of work. I must admit, I'm not likely to get to this right away; but I'd welcome any patches that can help along the way.

skyl commented 14 years ago

Right, I spent the better part of a day trying to hack this together but came up a bit short. I did basically come to the conclusion that it would probably be better (from my perspective) to have a new InfoMapMulti widget rather than trying to overload the existing InfoMap. The infoArray as a single array runs pretty deep though it seems...

skyl commented 14 years ago

woot! You might want to alter some of the implementation details; but, as far as I have tested, I have this working well here: http://github.com/skyl/olwidget/commit/21ab2b48910ead5227b8cf7bd0141e69bce4418e

olmap = InfoMapMulti(info_dict, options=options)

Where info_dict is like {'mylayer': info_array, 'otherlayer': info_array}. Then in the layer-switcher control you can check and uncheck "mylayer" and "otherlayer" and view the popups and close them, etc. Everything appears to be working with separate clustering and everything. I'm going to put it through some tougher paces today :-) I basically got it working and pushed the changes and went right to sleep.

Edit: I now have the problem of making both vectorLayers simultaneously clickable that you mentioned before. Hmm, maybe you didn't mention it, I just got the idea from browsing the examples. To make it work how I want it to, I need to tie in action like http://openlayers.org/dev/examples/select-feature-multilayer.html

skyl commented 14 years ago

and that is done here: http://github.com/skyl/olwidget/commit/87fe0075638034129084ad385ddefd1276bbb841

yourcelf commented 14 years ago

This is awesome, thanks. I'll take a look at this a bit later.

skyl commented 14 years ago

The current status is that I have to pass more style with each feature than I should. The current implementation solves the problems that I was having but doesn't fit as nicely with your style api as I would like.

I'm pretty sure that your most recent changes alter this landscape and perhaps address the problem that I was having but I haven't tried to merge in your most recent commit.

yourcelf commented 14 years ago

Here's a concept for a complete rework of olwidget to do the "right thing" with multiple vector layers through and through. First, eliminate the different "map types" (e.g. InfoMap, EditableMap). There should be only one map type, but there can be multiple "layer types" -- an "Info" layer type, an "Editable" layer type. Construct a base map, and then add any number of InfoLayer and EditableLayer layers to it. Each layer object has its own properties (clustering, styling, etc.), but they can all inherit from base layer options passed to the map constructor (so you can apply the same options over all layers if you like).

Some UI would have to exist to more aptly choose which layer is currently being edited, when there are multiple editable maps. It might be worth it to put some effort into improving the UI for editing anyway -- it's not that obvious to the uninitiated how to start and stop editing (versus panning the map), and the layer chooser is a little obtuse to those not familiar with OpenLayers.

Thoughts?

yourcelf commented 14 years ago

Here's a first stab at this concept, which amounts to almost a complete rewrite. It has rudimentary Info maps working, and not much else: http://github.com/yourcelf/olwidget/tree/multi

See "doc/examples/testmulti.html" and "js/multiolwidget.js".

yourcelf commented 14 years ago

Checkout the multi branch:

git clone git://github.com/yourcelf/olwidget.git --branch=multi

Multi-layer is totally rocking, along with a lot of other new stuff.

yourcelf commented 13 years ago

Closing this -- Multi-layer has been in master (v0.4) for some time now.