olwidget documentation?

14 views
Skip to first unread message

Todd Blanchard

unread,
Nov 21, 2009, 8:39:56 PM11/21/09
to geod...@googlegroups.com
I'm trying to come to grips with python, django, geodjango, and
olwidget all at the same time (I know, I know).

I've previously written an app using the Google Map apis using json,
php, and fixed decimal fields in mysql for lat or long values so I'm
quite familiar with those.

I can't seem to figure out how I integrate olwidget with my code and
how to configure it to make use of google maps rather than the open
layer stuff. The google maps have more detail and I need that.

Any pointers to how it all fits together would be most welcome.

Thanks,
-Todd Blanchard

Skylar Saveland

unread,
Nov 22, 2009, 4:05:34 PM11/22/09
to geod...@googlegroups.com
http://github.com/yourcelf/olwidget/blob/master/doc/django-olwidget.rst

There's good documentation there.  Using olwidget (InfoMap, MapDisplay, etc) gives you an openlayers map object on the page so further manipulations can be done with the full power of the open layers api.  Actually, http://github.com/yourcelf/olwidget/blob/master/django-olwidget/olwidget/templates/olwidget/info_map.html ... you can change to
    var my_map_on_the_page = new olwidget.InfoMap("{{ id }}", {{ info_array|safe }}, {{ map_opts|safe }});

so then you can run methods on my_map_on_the_page. I think that this is now a real openlayers map object whereas before you could call methods on my_map_on_the_page.map as the OL map object.

You may want to interact directly with google maps api (olwidget is for openlayers api which supports google layers but is not the same as the goog javascript api).
In this case, you can just send the data to the template as usual and {{ mymodel.my_geom_field.... }} to get the lat/lon and what-not out of the db and into some goog javascript.

Skylar



--

You received this message because you are subscribed to the Google Groups "geodjango" group.
To post to this group, send email to geod...@googlegroups.com.
To unsubscribe from this group, send email to geodjango+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/geodjango?hl=.



Todd Blanchard

unread,
Nov 22, 2009, 5:07:25 PM11/22/09
to geod...@googlegroups.com
OK, that was fabulously helpful.  I've got the admin pages doing useful things using google layers with polygons and points on a couple records.

I'm a lot more familiar with the google maps api so can someone summarize the advantages to picking one over the other?  First to come to mind is that people are more familiar with google maps UI widgets, the info window (balloon info thingy - is there an equivalent here?) and street view magical goodness.

Biggest advantage of OL seems to be I can pull from more data sources - yahoo and such and integrate them together.

-Todd Blanchard

Skylar Saveland

unread,
Nov 22, 2009, 5:43:20 PM11/22/09
to geod...@googlegroups.com
Well, open layers is BSD licensed so it's as open source as GeoDjango itself.  Google has different terms.  That's certainly one of the key differences you'll have to consider based on the nature of your project.  Balloon Info thingy certainly has more potential for customization with OL I would say, after all, the code is open ;)  Getting started with goog or openlayers (with olwidget) should be equally easy.

http://dev.openlayers.org/
http://openlayers.org/dev/examples/

I'll eventually put up some crummy screencasts that will show how to do some of this at http://skyl.org/videos/, feel free to do the same!

Todd Blanchard

unread,
Nov 22, 2009, 8:59:54 PM11/22/09
to geod...@googlegroups.com
Thanks.  

Something I haven't been able to figure out - how does the javascript get properly included in the head part of the document?

I'm starting a new site, working on base templates, not quite sure how to structure this so I get the static assets (css,js) properly referenced from the template.  olwidget apparently sticks them into some important block variable but I can't find it.

-Todd

Skylar Saveland

unread,
Nov 22, 2009, 9:18:59 PM11/22/09
to geod...@googlegroups.com
Template inheritance is outside of the scope of geod...@googlegroups.com.  You'll have to checkout the template inheritance docs:

http://docs.djangoproject.com/en/dev/topics/templates/#template-inheritance

Reply all
Reply to author
Forward
0 new messages