logo
examples Examples
  • Random machine
  • Multiply example
  • Simple Form
  • Django Forms
  • Map example
  • Flickr in place editor
  • Pagination example

dajaxproject

django+ajax

Map Machine!

Explanation

In this example, by clicking on the "request points" buttom, it will load three points over the map.
By dragging and dropping the points in the map we will send the new coordenates to the server.
Once they are in the server, it will send them back as a log message to the #example_log element.

ajax.py

		from dajax.core import Dajax
        from dajaxice.decorators import dajaxice_register

        @dajaxice_register
		def request_points(request):
			dajax = Dajax()

			points = []
			points.append({'lat':37.4144479875189,'lng':-122.091622352600,'text':'Some Site #1'})
			points.append({'lat':37.41206192930792,'lng':-122.0858287811279,'text':'Other Site #2'})
			points.append({'lat':37.4130163617132,'lng':-122.078061103820,'text':'Other Site #3'})

			dajax.addData(points,'example_draw_points')
			dajax.assign('#example_log','value',"3 Points loaded...")
			return dajax.json()


        @dajaxice_register
		def move_point(request, lat, lng):
			dajax = Dajax()
			message = "Saved new location at, %s, %s" % (lat, lng)
			dajax.assign('#example_log','value',message)
			return dajax.json()

	

JS

		function example_draw_points(data){
			for (var i=0; i < data.length; i++) {
				Map.create_dragable_point(data[i].lat,data[i].lng,i);
			};
		}
	

html

		
downloads Download   documentation Documentation   bugs Bugs
mail Any issues? Join our mailing list now!
Copyright © 2010 Jorge Bastida | icons by Joseph Wain