Re: [flask] Map field in Flask
- Marko Djordjevic
- 2012-06-13 @ 11:15
Thank you for your response, that was my idea but it means a lot to know
I'm on right track.
It is one-afternoon project, but I would like to make it reusable with
wtforms later, to help myself and others.
I have chosen http://mapstraction.com/ library, it seams pretty nice and
full of features.
On Tue, Jun 12, 2012 at 8:48 AM, Honza Javorek <firstname.lastname@example.org> wrote:
> client's side working on "final" HTML code generated and sent from
> server (e.g. by Flask).
> easily work with the map and display it. Something like Google Maps
> API library, but for OpenStreet Maps. Once you append it, you can
> write another simple script (e.g. using jQuery framework, which is
> pretty easy to learn) to listen user's clicks on the map (map library
> should have interface for that) and record corresponding coordinates.
> Then you can have a hidden field in your form (which can be easily
> added by WTForms on Flask's side, or just manually written in Jinja2
> if it's only one-afternoon-project), where you can "secretly" record
> these values (latitude, longitude) on user's click. On form submission
> Flask has the data in this field (i.e. in request form params) and can
> do with it whatever you want or need.
> You could, of course, make your own field widget extending WTForms,
> unifying all this, but that's up to you and depends on how you need it
> to be reusable. Also, you'd need to read further docs on WTForms how
> to make your own form elements, etc. If you are only trying, you won't
> probably gain any benefits (reusability) from this approach except of
> deeper experience with WTForms.
> And to answer the second part of your last sentence, I haven't
> searched for such ready-made solution, but I doubt someone already did
> it and prepared it. If you can achieve it and if you can make it
> reusable and useful also for others, start your own Flask extension
> and make the world a better place for drinking flasks over maps :-)
> Good luck,
> On Mon, Jun 11, 2012 at 9:34 AM, Marko Djordjevic
> <email@example.com> wrote:
> > I would like to make simple event application with flask just to try
> > out, events would be shown on map (openstreetmap).
> > Is there example integrating maps with Flask and/or WTForms field for
> > choosing coordinates on map.
> > I know it would not be too hard to write it, but if someone has already
> > it, I would like to use it.
> > Thanks,
> > Marko.