File tree Expand file tree Collapse file tree 4 files changed +35
-3
lines changed Expand file tree Collapse file tree 4 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,9 @@ Installation
1717 pip install django-easy-maps
1818
1919Then add 'easy_maps' to INSTALLED_APPS and run ``./manage.py syncdb ``
20- (or ``./manage.py migrate easy_maps `` if South is in use)
20+ (or ``./manage.py migrate easy_maps `` if South is in use). Since there are
21+ some media files needed to be used, you have to collect the static files
22+ distributed with this application (using ``./manage collectstatic ``).
2123
2224Settings
2325========
Original file line number Diff line number Diff line change 1+ // will contain the boundary of the map.
2+ var g_lat_long_bound = new google . maps . LatLngBounds ( ) ;
3+
4+ function easy_map_add_listener ( id , marker ) {
5+ // update the coordinate on marker dragging
6+ google . maps . event . addListener ( marker , 'dragend' , function ( evt ) {
7+ var ll = marker . getPosition ( ) ;
8+ // FIXME: fix id names
9+ document . getElementById ( id + 'latitude' ) . value = ll . lat ( ) ;
10+ document . getElementById ( id + 'longitude' ) . value = ll . lng ( ) ;
11+ } ) ;
12+ }
13+
14+ function easy_maps_add_marker ( map , marker ) {
15+ var latlng = new google . maps . LatLng ( marker . latitude , marker . longitude ) ;
16+ var marker = new google . maps . Marker ( {
17+ position : latlng ,
18+ map : map ,
19+ draggable : true ,
20+ title : marker . address
21+ } ) ;
22+
23+ // add marker's coordinate to the boundary
24+ g_lat_long_bound . extend ( latlng ) ;
25+
26+ return marker ;
27+ }
Original file line number Diff line number Diff line change 33{% with longitude|stringformat:"f" as long %}
44
55{% block api_js %}
6- <!-- Google Maps API javascript -->
7- < script type ="text/javascript " src ="https://maps.google.com/maps/api/js?sensor=false "> </ script >
86{% endblock %}
97
108{% block html %}
Original file line number Diff line number Diff line change 22from django .template import Template , Context
33
44class AddressWithMapWidget (TextInput ):
5+ class Media :
6+ js = (
7+ 'https://maps.google.com/maps/api/js?sensor=false' ,
8+ 'js/easy_maps.js' ,
9+ )
510 def render (self , name , value , attrs = None ):
611 # retrieve the field's id otherwise it's not possible
712 # to use correctly the JS
You can’t perform that action at this time.
0 commit comments