philippbosch / django-geoposition

Django model field that can hold a geoposition, and corresponding widget
http://django-geoposition.rtfd.org/
MIT License
331 stars 204 forks source link

How to show results in template after submitting form #22

Closed edopolimac closed 10 years ago

edopolimac commented 10 years ago

Great app. I' am trying to display results after submitting form, but i have trouble with that (beginner). Regular form and admin are working ok. Simple example: views.py def article(request): article = PointOfInterest.objects.get(id=1) args['article'] = article return render_to_response('article.html', args, context_instance=RequestContext(request)) article.html ??? Can you provide extension on how to do this step with displaying result with pointer after submitting form?

edopolimac commented 10 years ago

So far i find this solution, it's working ok, only zoom isn't working like in geoposition.js. Must set zoom number.

function initialize() { var myLatlng = new google.maps.LatLng({{ article.position }}); var mapOptions = { zoom: 12, center: myLatlng } var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

var marker = new google.maps.Marker({ position: myLatlng, map: map, title: 'Hello World!' }); }

google.maps.event.addDomListener(window, 'load', initialize); div id="map-canvas" style="width: 800px; height: 600px"

philippbosch commented 10 years ago

In 748b76dad8ece3a4a14f186072d02a1a120b0870 I added an example view and template that should show how to display geopositions on a map.