Merge lp:~ronnie.vd.c/loco-team-portal/570613 into lp:loco-team-portal
- 570613
- Merge into 0.2
Proposed by
Ronnie
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 393 | ||||||||
Proposed branch: | lp:~ronnie.vd.c/loco-team-portal/570613 | ||||||||
Merge into: | lp:loco-team-portal | ||||||||
Diff against target: |
749 lines (+445/-157) 12 files modified
loco_directory/events/models.py (+3/-0) loco_directory/events/urls.py (+1/-0) loco_directory/events/views.py (+24/-2) loco_directory/media/css/newstyle.css (+3/-15) loco_directory/media/js/common.js (+0/-103) loco_directory/media/js/jquery-ubuntu-maps.js (+373/-0) loco_directory/templates/events/global_event_detail.html (+12/-1) loco_directory/templates/events/global_event_detail.inc.html (+4/-1) loco_directory/templates/venues/venue_detail.html (+3/-4) loco_directory/templates/venues/venue_detail.inc.html (+7/-9) loco_directory/templates/venues/venue_update.html (+12/-18) loco_directory/venues/forms.py (+3/-4) |
||||||||
To merge this branch: | bzr merge lp:~ronnie.vd.c/loco-team-portal/570613 | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Hall (community) | Approve | ||
Review via email: mp+50194@code.launchpad.net |
Commit message
Description of the change
Google Maps are added to the pages "global event" and "venue add/update/
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'loco_directory/events/models.py' | |||
2 | --- loco_directory/events/models.py 2011-01-18 20:38:55 +0000 | |||
3 | +++ loco_directory/events/models.py 2011-02-17 17:57:17 +0000 | |||
4 | @@ -107,6 +107,9 @@ | |||
5 | 107 | 107 | ||
6 | 108 | def random_5_attendees(self): | 108 | def random_5_attendees(self): |
7 | 109 | return Attendee.objects.filter(event__id__exact=self.id).order_by('?')[5:] | 109 | return Attendee.objects.filter(event__id__exact=self.id).order_by('?')[5:] |
8 | 110 | |||
9 | 111 | def has_location(self): | ||
10 | 112 | return self.filter(venue__longitude__isnull=False, venue__latitude__isnull=False) | ||
11 | 110 | 113 | ||
12 | 111 | class TeamEvent(BaseEvent): | 114 | class TeamEvent(BaseEvent): |
13 | 112 | """ | 115 | """ |
14 | 113 | 116 | ||
15 | === modified file 'loco_directory/events/urls.py' | |||
16 | --- loco_directory/events/urls.py 2010-12-19 21:25:01 +0000 | |||
17 | +++ loco_directory/events/urls.py 2011-02-17 17:57:17 +0000 | |||
18 | @@ -22,6 +22,7 @@ | |||
19 | 22 | url(r'^global/(?P<global_event_id>\d+)/detail/$', 'events.views.global_event_detail', name='global-event-detail'), | 22 | url(r'^global/(?P<global_event_id>\d+)/detail/$', 'events.views.global_event_detail', name='global-event-detail'), |
20 | 23 | url(r'^global/(?P<global_event_id>\d+)/delete/$', 'events.views.global_event_delete', name='global-event-delete'), | 23 | url(r'^global/(?P<global_event_id>\d+)/delete/$', 'events.views.global_event_delete', name='global-event-delete'), |
21 | 24 | url(r'^global/(?P<global_event_id>\d+)/update/$', 'events.views.global_event_update', name='global-event-update'), | 24 | url(r'^global/(?P<global_event_id>\d+)/update/$', 'events.views.global_event_update', name='global-event-update'), |
22 | 25 | url(r'^global/(?P<global_event_id>\d+)/locations/$', 'events.views.global_event_locations', name='global-event-locations'), | ||
23 | 25 | url(r'^global/add/$', 'events.views.global_event_new', name='global-event-new'), | 26 | url(r'^global/add/$', 'events.views.global_event_new', name='global-event-new'), |
24 | 26 | 27 | ||
25 | 27 | ) | 28 | ) |
26 | 28 | 29 | ||
27 | === modified file 'loco_directory/events/views.py' | |||
28 | --- loco_directory/events/views.py 2011-02-02 17:40:39 +0000 | |||
29 | +++ loco_directory/events/views.py 2011-02-17 17:57:17 +0000 | |||
30 | @@ -3,6 +3,7 @@ | |||
31 | 3 | from django.shortcuts import render_to_response | 3 | from django.shortcuts import render_to_response |
32 | 4 | from django.shortcuts import get_object_or_404 | 4 | from django.shortcuts import get_object_or_404 |
33 | 5 | from django.contrib.auth.decorators import login_required | 5 | from django.contrib.auth.decorators import login_required |
34 | 6 | from django.utils import simplejson | ||
35 | 6 | from django.utils.translation import ugettext as _ | 7 | from django.utils.translation import ugettext as _ |
36 | 7 | from django.core.urlresolvers import reverse | 8 | from django.core.urlresolvers import reverse |
37 | 8 | 9 | ||
38 | @@ -471,5 +472,26 @@ | |||
39 | 471 | return redirect( global_event_object ) | 472 | return redirect( global_event_object ) |
40 | 472 | 473 | ||
41 | 473 | 474 | ||
44 | 474 | 475 | def global_event_locations(request, global_event_id): | |
45 | 475 | 476 | """ | |
46 | 477 | the longitude and latitude global event | ||
47 | 478 | """ | ||
48 | 479 | global_event_object = get_object_or_404(GlobalEvent, pk=global_event_id) | ||
49 | 480 | locations = [] | ||
50 | 481 | for event in global_event_object.teamevent_set.has_location(): | ||
51 | 482 | location = {} | ||
52 | 483 | location['url'] = event.get_absolute_url() | ||
53 | 484 | location['title'] = event.name | ||
54 | 485 | # TODO: create an separate view with template for the content | ||
55 | 486 | location['content'] = '<p>Location: <a href="%s">%s</a></p><p>Start date: %s</p><p>End date: %s</p>' % (event.get_absolute_url(), | ||
56 | 487 | event.venue.name, | ||
57 | 488 | str(event.date_begin), | ||
58 | 489 | str(event.date_end)) | ||
59 | 490 | location['lng'] = event.venue.longitude | ||
60 | 491 | location['lat'] = event.venue.latitude | ||
61 | 492 | locations.append(location) | ||
62 | 493 | |||
63 | 494 | json = simplejson.dumps(locations) | ||
64 | 495 | |||
65 | 496 | return HttpResponse(json) | ||
66 | 497 | |||
67 | 476 | 498 | ||
68 | === modified file 'loco_directory/media/css/newstyle.css' | |||
69 | --- loco_directory/media/css/newstyle.css 2011-02-03 01:43:39 +0000 | |||
70 | +++ loco_directory/media/css/newstyle.css 2011-02-17 17:57:17 +0000 | |||
71 | @@ -25,21 +25,9 @@ | |||
72 | 25 | white-space: nowrap; | 25 | white-space: nowrap; |
73 | 26 | } | 26 | } |
74 | 27 | 27 | ||
90 | 28 | #venue-map-selector { | 28 | .minor-content.venue-map { |
91 | 29 | width: 400px; | 29 | min-height: 350px; |
92 | 30 | height: 300px; | 30 | margin-top: 60px; |
78 | 31 | border: 1px solid #ccc; | ||
79 | 32 | position: absolute; | ||
80 | 33 | right: 30px; | ||
81 | 34 | top: 40px; | ||
82 | 35 | } | ||
83 | 36 | #venue-map { | ||
84 | 37 | width: 400px; | ||
85 | 38 | border: 1px solid #CCC; | ||
86 | 39 | bottom: 10px; | ||
87 | 40 | float: right; | ||
88 | 41 | height: 300px; | ||
89 | 42 | margin-right: 10px; | ||
93 | 43 | } | 31 | } |
94 | 44 | 32 | ||
95 | 45 | #main-content { | 33 | #main-content { |
96 | 46 | 34 | ||
97 | === added file 'loco_directory/media/img/ajax-loader.gif' | |||
98 | 47 | Binary files loco_directory/media/img/ajax-loader.gif 1970-01-01 00:00:00 +0000 and loco_directory/media/img/ajax-loader.gif 2011-02-17 17:57:17 +0000 differ | 35 | Binary files loco_directory/media/img/ajax-loader.gif 1970-01-01 00:00:00 +0000 and loco_directory/media/img/ajax-loader.gif 2011-02-17 17:57:17 +0000 differ |
99 | === added file 'loco_directory/media/img/marker.png' | |||
100 | 48 | Binary files loco_directory/media/img/marker.png 1970-01-01 00:00:00 +0000 and loco_directory/media/img/marker.png 2011-02-17 17:57:17 +0000 differ | 36 | Binary files loco_directory/media/img/marker.png 1970-01-01 00:00:00 +0000 and loco_directory/media/img/marker.png 2011-02-17 17:57:17 +0000 differ |
101 | === removed file 'loco_directory/media/js/common.js' | |||
102 | --- loco_directory/media/js/common.js 2010-06-09 01:36:18 +0000 | |||
103 | +++ loco_directory/media/js/common.js 1970-01-01 00:00:00 +0000 | |||
104 | @@ -1,103 +0,0 @@ | |||
105 | 1 | //Click Control to get lonlat values. trigger function set the values | ||
106 | 2 | OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { | ||
107 | 3 | defaultHandlerOptions: { | ||
108 | 4 | 'single': true, | ||
109 | 5 | 'double': false, | ||
110 | 6 | 'pixelTolerance': 0, | ||
111 | 7 | 'stopSingle': false, | ||
112 | 8 | 'stopDouble': false | ||
113 | 9 | }, | ||
114 | 10 | |||
115 | 11 | initialize: function(options) { | ||
116 | 12 | this.handlerOptions = OpenLayers.Util.extend( | ||
117 | 13 | {}, this.defaultHandlerOptions | ||
118 | 14 | ); | ||
119 | 15 | OpenLayers.Control.prototype.initialize.apply( | ||
120 | 16 | this, arguments | ||
121 | 17 | ); | ||
122 | 18 | this.handler = new OpenLayers.Handler.Click( | ||
123 | 19 | this, { | ||
124 | 20 | 'click': this.trigger | ||
125 | 21 | }, this.handlerOptions | ||
126 | 22 | ); | ||
127 | 23 | }, | ||
128 | 24 | |||
129 | 25 | trigger: function(e) { | ||
130 | 26 | var lonlat = map.getLonLatFromViewPortPx(e.xy); | ||
131 | 27 | $("#id_longitude").val(lonlat.lon) | ||
132 | 28 | $("#id_latitude").val(lonlat.lat) | ||
133 | 29 | map.markers.erase(); | ||
134 | 30 | //alert("You clicked near " + lonlat.lat + " N, " + lonlat.lon + " E"); | ||
135 | 31 | } | ||
136 | 32 | |||
137 | 33 | }); | ||
138 | 34 | //function to add markers to map | ||
139 | 35 | function addMarker(layer, lon, lat, popupContentHTML) { | ||
140 | 36 | var ll = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()); | ||
141 | 37 | var feature = new OpenLayers.Feature(layer, ll); | ||
142 | 38 | feature.closeBox = true; | ||
143 | 39 | feature.popupClass = OpenLayers.Class(OpenLayers.Popup.FramedCloud, { minSize: new OpenLayers.Size(200, 100) }); | ||
144 | 40 | feature.data.popupContentHTML = popupContentHTML; | ||
145 | 41 | feature.data.overflow = "hidden"; | ||
146 | 42 | |||
147 | 43 | var marker = new OpenLayers.Marker(ll); | ||
148 | 44 | marker.feature = feature; | ||
149 | 45 | |||
150 | 46 | var markerClick = function(evt) { | ||
151 | 47 | if (this.popup == null) { | ||
152 | 48 | this.popup = this.createPopup(this.closeBox); | ||
153 | 49 | map.addPopup(this.popup); | ||
154 | 50 | this.popup.show(); | ||
155 | 51 | } else { | ||
156 | 52 | this.popup.toggle(); | ||
157 | 53 | } | ||
158 | 54 | OpenLayers.Event.stop(evt); | ||
159 | 55 | }; | ||
160 | 56 | marker.events.register("mousedown", feature, markerClick); | ||
161 | 57 | |||
162 | 58 | layer.addMarker(marker); | ||
163 | 59 | } | ||
164 | 60 | |||
165 | 61 | //openlayers map | ||
166 | 62 | var map; | ||
167 | 63 | function showmap(divid, select, lon, lat, htmltext){ | ||
168 | 64 | map = new OpenLayers.Map(divid); | ||
169 | 65 | map.addControl(new OpenLayers.Control.LayerSwitcher()); | ||
170 | 66 | var gphy = new OpenLayers.Layer.Google( | ||
171 | 67 | "Google Physical", | ||
172 | 68 | {type: G_PHYSICAL_MAP} | ||
173 | 69 | ); | ||
174 | 70 | var gmap = new OpenLayers.Layer.Google( | ||
175 | 71 | "Google Streets", // the default | ||
176 | 72 | {numZoomLevels: 20} | ||
177 | 73 | ); | ||
178 | 74 | var ghyb = new OpenLayers.Layer.Google( | ||
179 | 75 | "Google Hybrid", | ||
180 | 76 | {type: G_HYBRID_MAP, numZoomLevels: 20} | ||
181 | 77 | ); | ||
182 | 78 | var gsat = new OpenLayers.Layer.Google( | ||
183 | 79 | "Google Satellite", | ||
184 | 80 | {type: G_SATELLITE_MAP, numZoomLevels: 22} | ||
185 | 81 | ); | ||
186 | 82 | var markers = new OpenLayers.Layer.Markers("Markers Layer"); | ||
187 | 83 | |||
188 | 84 | map.addLayers([gphy, ghyb, gsat, markers]); | ||
189 | 85 | if (lon === undefined && lat === undefined) { | ||
190 | 86 | map.setCenter(new OpenLayers.LonLat(0, 0), 0); | ||
191 | 87 | } else { | ||
192 | 88 | for (i=0;i<lon.length;i++) { | ||
193 | 89 | addMarker(markers, lon[i], lat[i], htmltext[i]); | ||
194 | 90 | } | ||
195 | 91 | var lonLat = new OpenLayers.LonLat(lon[0], lat[0]).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()); | ||
196 | 92 | map.setCenter (lonLat, 6); | ||
197 | 93 | } | ||
198 | 94 | //map.zoomToMaxExtent(); | ||
199 | 95 | if (select) { | ||
200 | 96 | var click = new OpenLayers.Control.Click(); | ||
201 | 97 | map.addControl(click); | ||
202 | 98 | click.activate(); | ||
203 | 99 | } | ||
204 | 100 | |||
205 | 101 | |||
206 | 102 | } | ||
207 | 103 | |||
208 | 104 | 0 | ||
209 | === added file 'loco_directory/media/js/jquery-ubuntu-maps.js' | |||
210 | --- loco_directory/media/js/jquery-ubuntu-maps.js 1970-01-01 00:00:00 +0000 | |||
211 | +++ loco_directory/media/js/jquery-ubuntu-maps.js 2011-02-17 17:57:17 +0000 | |||
212 | @@ -0,0 +1,373 @@ | |||
213 | 1 | /* | ||
214 | 2 | * jQuery Google Map Plugin 0.2.3 | ||
215 | 3 | * https://wiki.ubuntu.com/ubuntu-django-foundations/map | ||
216 | 4 | * Requires jQuery 1.4.2 | ||
217 | 5 | * | ||
218 | 6 | * Copyright 2011, Ronnie van den Crommenacker | ||
219 | 7 | * Dual licensed under the MIT or GPL Version 2 licenses. | ||
220 | 8 | * http://jquery.org/license | ||
221 | 9 | */ | ||
222 | 10 | |||
223 | 11 | (function ($) { | ||
224 | 12 | $.fn.extend({ | ||
225 | 13 | showLocations: function (options) { | ||
226 | 14 | var defaults = { | ||
227 | 15 | markers_url: null, // http://link/to/json/markers or /link/to/json/markers | ||
228 | 16 | markers_list: null, // [ {lat: 0.345, lng: 0.3456}, {lat: 44.345, lng: 34.3456} ] | ||
229 | 17 | position_name: { | ||
230 | 18 | lat: 'lat', // { lat: 0.4567, lng: 0.2345 } | ||
231 | 19 | lng: 'lng' // { lat: 0.4567, lng: 0.2345 } | ||
232 | 20 | }, | ||
233 | 21 | marker_content_url: null, // The url to load when clicked on a marker | ||
234 | 22 | marker_content_tmpl: null, // The template to load when clicked on a marker | ||
235 | 23 | mapOptions: { | ||
236 | 24 | zoom: 2, | ||
237 | 25 | center: new google.maps.LatLng(22, 12), | ||
238 | 26 | mapTypeId: google.maps.MapTypeId.ROADMAP, | ||
239 | 27 | mapTypeControl: false | ||
240 | 28 | }, | ||
241 | 29 | user_location_zoom: 7, // use null to disable this feature | ||
242 | 30 | single_marker_zoom: 7, // the zoomlevel. use null to disable | ||
243 | 31 | ajax_load_error: '<p>The page could not be loaded</p>', | ||
244 | 32 | ajax_load_icon: '/ubuntu-website/media/images/ajax-loader.gif', | ||
245 | 33 | marker_icon: null, | ||
246 | 34 | cluster_tmpl: null, | ||
247 | 35 | filter: null, //[ { element: $('...'), attrs: { attr: value }}, { element: $('...'), attrs: { attr: value }} ] | ||
248 | 36 | mcOptions: { gridSize: 40, maxZoom: 10, zoomOnClick: false//, styles: [ | ||
249 | 37 | //{ url: 'images/supportCluster1.png', height: 48, width: 48, opt_anchor: [16, 0], opt_textColor: '#ffffff', opt_textSize: 10 }, /* 2-9 members */ | ||
250 | 38 | //{ url: 'images/supportCluster2.png', height: 64, width: 64, opt_anchor: [24, 0], opt_textColor: '#ffffff', opt_textSize: 11 }, /* 10-99 members */ | ||
251 | 39 | //{ url: 'images/supportCluster3.png', height: 96, width: 96, opt_anchor: [32, 0], opt_textColor: '#ffffff', opt_textSize: 12 }, /* 100-999 members */ | ||
252 | 40 | //{ url: 'images/supportCluster4.png', height: 128, width: 128, opt_anchor: [32, 0], opt_textColor: '#ffffff', opt_textSize: 12 } /* 1000+ members */ | ||
253 | 41 | //] | ||
254 | 42 | } | ||
255 | 43 | }, | ||
256 | 44 | // Add the window where the details are shown when clicked on a marker | ||
257 | 45 | infowindow = new google.maps.InfoWindow(); | ||
258 | 46 | |||
259 | 47 | options = $.extend(defaults, options); | ||
260 | 48 | |||
261 | 49 | // TODO: rewrite this one | ||
262 | 50 | function getAjaxLoader() { | ||
263 | 51 | var ajaximg = $('<img src="' + options.ajax_load_icon + '" />') | ||
264 | 52 | .attr({'style': 'display:inline-block;vertical-align:middle;margin-right:10px;'}), | ||
265 | 53 | ajaxtxt = $('<p>') | ||
266 | 54 | .attr({'style': 'display:inline-block;vertical-align:middle;'}) | ||
267 | 55 | .html('Retrieving data<br />from server...'), | ||
268 | 56 | wrapper = $('<div>') | ||
269 | 57 | .attr({'style': 'margin:auto;width:130px;'}); | ||
270 | 58 | return wrapper.append(ajaximg).append(ajaxtxt)[0]; | ||
271 | 59 | } | ||
272 | 60 | |||
273 | 61 | infowindow.show = function (html, pos) { | ||
274 | 62 | this.setContent(html); | ||
275 | 63 | this.setPosition(pos); | ||
276 | 64 | this.open(this.map); | ||
277 | 65 | }; | ||
278 | 66 | infowindow.ajaxloader = null; | ||
279 | 67 | infowindow.showLoader = function (pos) { | ||
280 | 68 | // Set a temporary loader while the data is retreved from the server | ||
281 | 69 | if (this.ajaxloader === null) { | ||
282 | 70 | // TODO: allow user defined ajax loader | ||
283 | 71 | this.ajaxloader = getAjaxLoader(); | ||
284 | 72 | } | ||
285 | 73 | this.show(this.ajaxloader, pos); | ||
286 | 74 | }; | ||
287 | 75 | infowindow.showTemplate = function (url, data, pos) { | ||
288 | 76 | var $data = data, | ||
289 | 77 | $pos = pos, | ||
290 | 78 | ifw = this; | ||
291 | 79 | |||
292 | 80 | if (!$.tmpl) { | ||
293 | 81 | alert('jQuery.tmpl is not installed\nYou can download here:\nhttp://github.com/jquery/jquery-tmpl'); | ||
294 | 82 | return false; | ||
295 | 83 | } | ||
296 | 84 | |||
297 | 85 | this.showLoader(pos); | ||
298 | 86 | $.ajax({ | ||
299 | 87 | url: url, | ||
300 | 88 | dataType: 'html', | ||
301 | 89 | success: function (template) { | ||
302 | 90 | ifw.show($(template).tmpl($data)[0], $pos); | ||
303 | 91 | }, | ||
304 | 92 | error: function () { | ||
305 | 93 | ifw.show(options.ajax_load_error, $pos); | ||
306 | 94 | } | ||
307 | 95 | }); | ||
308 | 96 | }; | ||
309 | 97 | infowindow.showHTML = function (url, pos) { | ||
310 | 98 | var $pos = pos, | ||
311 | 99 | ifw = this; | ||
312 | 100 | |||
313 | 101 | this.showLoader(pos); | ||
314 | 102 | //TODO: Check for better same-origin in url | ||
315 | 103 | if (url.slice(0, 4) == 'http'){ | ||
316 | 104 | ifw.show($('<iframe>').attr('src', url)[0], $pos); | ||
317 | 105 | } else { | ||
318 | 106 | $.ajax({ | ||
319 | 107 | url: url, | ||
320 | 108 | dataType: 'html', | ||
321 | 109 | success: function (html) { | ||
322 | 110 | ifw.show(html, $pos); | ||
323 | 111 | }, | ||
324 | 112 | error: function () { | ||
325 | 113 | ifw.show(options.ajax_load_error, $pos); | ||
326 | 114 | } | ||
327 | 115 | }); | ||
328 | 116 | } | ||
329 | 117 | }; | ||
330 | 118 | |||
331 | 119 | // Constructs an url with ${...} together with data to a normal url | ||
332 | 120 | function constructUrl(url, marker) { | ||
333 | 121 | var pattern = /\$\{[\w\d]+\}/g, // match pattern for ${....} | ||
334 | 122 | url_match = url.match(pattern), // Matches the url for ${...} and returns a list of matches | ||
335 | 123 | param = null, // Used for getting a specific param from the marker | ||
336 | 124 | tag = null; // The tags in the match pattern | ||
337 | 125 | |||
338 | 126 | for (tag in url_match) { | ||
339 | 127 | if (url_match.hasOwnProperty(tag)) { | ||
340 | 128 | param = url_match[tag]; | ||
341 | 129 | url = url.replace(param, marker[param.slice(2, param.length - 1)]); | ||
342 | 130 | } | ||
343 | 131 | } | ||
344 | 132 | return url; | ||
345 | 133 | } | ||
346 | 134 | |||
347 | 135 | // Function executed when clicked on a cluster object | ||
348 | 136 | function clusterClicked(cluster) { | ||
349 | 137 | if (options.cluster_tmpl) { | ||
350 | 138 | infowindow.showTemplate(options.cluster_tmpl, {marker_list: cluster[0].markers_}, cluster[0].getCenter()); | ||
351 | 139 | } | ||
352 | 140 | } | ||
353 | 141 | |||
354 | 142 | // Function that is executed when user clicks on a marker | ||
355 | 143 | function markerClicked() { | ||
356 | 144 | var url = null; | ||
357 | 145 | |||
358 | 146 | if (options.marker_content_url) { | ||
359 | 147 | url = constructUrl(options.marker_content_url, this); | ||
360 | 148 | infowindow.showHTML(url, this.position); | ||
361 | 149 | } else if (options.marker_content_tmpl) { | ||
362 | 150 | infowindow.showTemplate(options.marker_content_tmpl, {marker: this}, this.position); | ||
363 | 151 | } | ||
364 | 152 | } | ||
365 | 153 | |||
366 | 154 | // Create from json data the google.maps.Marker and add them to the markercluster (mc) | ||
367 | 155 | // Then center the map if there is only one cluster and options.single_marker_zoom is true | ||
368 | 156 | function createMarkers(map, mc, markers) { | ||
369 | 157 | var marker_list = [], // A list of gmakers | ||
370 | 158 | marker = null, // The json of a marker | ||
371 | 159 | gmarker = null, // The actual google.maps.Marker() type | ||
372 | 160 | idx = null, // Index | ||
373 | 161 | lat = options.position_name.lat, // The parameter that contains the latitude | ||
374 | 162 | lng = options.position_name.lng; // The parameter that contains the longitude | ||
375 | 163 | |||
376 | 164 | if (markers[0].fields) { | ||
377 | 165 | // Django model | ||
378 | 166 | // Use django pk and fields parameters | ||
379 | 167 | for (idx in markers) { | ||
380 | 168 | if (markers.hasOwnProperty(idx)) { | ||
381 | 169 | marker = markers[idx].fields; | ||
382 | 170 | marker.pk = markers[idx].pk; | ||
383 | 171 | marker.position = new google.maps.LatLng(marker[lat], marker[lng]); | ||
384 | 172 | if (!marker.icon && options.marker_icon) { | ||
385 | 173 | marker.icon = options.marker_icon; | ||
386 | 174 | } | ||
387 | 175 | gmarker = new google.maps.Marker(marker); | ||
388 | 176 | google.maps.event.addDomListener(gmarker, 'click', markerClicked); | ||
389 | 177 | marker_list.push(gmarker); | ||
390 | 178 | } | ||
391 | 179 | } | ||
392 | 180 | |||
393 | 181 | } else { | ||
394 | 182 | // Use normal parameters | ||
395 | 183 | for (idx in markers) { | ||
396 | 184 | if (markers.hasOwnProperty(idx)) { | ||
397 | 185 | marker = markers[idx]; | ||
398 | 186 | marker.position = new google.maps.LatLng(marker[lat], marker[lng]); | ||
399 | 187 | if (!markers[idx].icon && options.marker_icon) { | ||
400 | 188 | marker.icon = options.marker_icon; | ||
401 | 189 | } | ||
402 | 190 | gmarker = new google.maps.Marker(marker); | ||
403 | 191 | google.maps.event.addDomListener(gmarker, 'click', markerClicked); | ||
404 | 192 | marker_list.push(gmarker); | ||
405 | 193 | } | ||
406 | 194 | } | ||
407 | 195 | } | ||
408 | 196 | mc.addMarkers(marker_list); | ||
409 | 197 | |||
410 | 198 | // If there is only one marker | ||
411 | 199 | if (options.single_marker_zoom && marker_list.length === 1) { | ||
412 | 200 | // Make sure the map is initialized | ||
413 | 201 | // FIXME: Look for an map.init event | ||
414 | 202 | setTimeout(function () { | ||
415 | 203 | map.setCenter(mc.getMarkers()[0].getPosition()); | ||
416 | 204 | map.setZoom(options.single_marker_zoom); | ||
417 | 205 | }, 100); | ||
418 | 206 | } | ||
419 | 207 | } | ||
420 | 208 | |||
421 | 209 | return $(this).each(function (i, html_element) { | ||
422 | 210 | var map = new google.maps.Map(html_element, options.mapOptions), | ||
423 | 211 | markerCluster = new MarkerClusterer(map, [], options.mcOptions), | ||
424 | 212 | filter = options.filter, | ||
425 | 213 | filterer = null, | ||
426 | 214 | index = null, | ||
427 | 215 | pos = null; | ||
428 | 216 | |||
429 | 217 | // FIXME: Manually override the zoomOnClick because of this bug | ||
430 | 218 | // http://www.devcomments.com/V3-MarkerClusterer-zoomOnClick-issue-at255452.htm | ||
431 | 219 | markerCluster.zoomOnClick_ = false; | ||
432 | 220 | |||
433 | 221 | // Attach the info window to the curernt map | ||
434 | 222 | infowindow.map = map; | ||
435 | 223 | |||
436 | 224 | // When clicked on a cluster, call the event | ||
437 | 225 | google.maps.event.addListener(markerCluster, 'clusterclick', clusterClicked); | ||
438 | 226 | |||
439 | 227 | // Try W3C Geolocation (Preferred) | ||
440 | 228 | // Ask the user for their location and set the map to it | ||
441 | 229 | if (options.user_location_zoom && navigator.geolocation) { | ||
442 | 230 | navigator.geolocation.getCurrentPosition(function (position) { | ||
443 | 231 | pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); | ||
444 | 232 | map.setCenter(pos); | ||
445 | 233 | map.setZoom(options.user_location_zoom); | ||
446 | 234 | }); | ||
447 | 235 | } | ||
448 | 236 | |||
449 | 237 | // Load the list of markers into the map | ||
450 | 238 | if (options.markers_url) { | ||
451 | 239 | $.get(options.markers_url, function (markers) { | ||
452 | 240 | createMarkers(map, markerCluster, markers); | ||
453 | 241 | }, 'json'); | ||
454 | 242 | } else if (options.markers_list) { | ||
455 | 243 | createMarkers(map, markerCluster, options.markers_list); | ||
456 | 244 | } | ||
457 | 245 | |||
458 | 246 | if (filter) { | ||
459 | 247 | filterer = (function (markerCluster) { | ||
460 | 248 | var mc = markerCluster, | ||
461 | 249 | markers = mc.getMarkers(); | ||
462 | 250 | return { | ||
463 | 251 | addFilter: function (filter) { | ||
464 | 252 | filter.element.click(function (event) { | ||
465 | 253 | var attrs = filter.attrs, | ||
466 | 254 | visible_markers = [], | ||
467 | 255 | m = null, | ||
468 | 256 | a = null; | ||
469 | 257 | |||
470 | 258 | event.preventDefault(); | ||
471 | 259 | |||
472 | 260 | for (m in markers) { | ||
473 | 261 | if (markers.hasOwnProperty(m)) { | ||
474 | 262 | marker = markers[m]; | ||
475 | 263 | for (a in attrs) { | ||
476 | 264 | if (attrs.hasOwnProperty(a)) { | ||
477 | 265 | if (marker[a] === attrs[a]) { | ||
478 | 266 | visible_markers.push(marker); | ||
479 | 267 | } | ||
480 | 268 | } | ||
481 | 269 | } | ||
482 | 270 | } | ||
483 | 271 | } | ||
484 | 272 | // If there are no filter options, show all markers | ||
485 | 273 | if (!a) { | ||
486 | 274 | visible_markers = markers; | ||
487 | 275 | } | ||
488 | 276 | mc.clearMarkers(); | ||
489 | 277 | mc.addMarkers(visible_markers, false); | ||
490 | 278 | }); | ||
491 | 279 | } | ||
492 | 280 | }; | ||
493 | 281 | }(markerCluster)); | ||
494 | 282 | for (index in filter) { | ||
495 | 283 | if (filter.hasOwnProperty(index)) { | ||
496 | 284 | filterer.addFilter(filter[index]); | ||
497 | 285 | } | ||
498 | 286 | } | ||
499 | 287 | } | ||
500 | 288 | }); | ||
501 | 289 | }, | ||
502 | 290 | selectLocation: function (options) { | ||
503 | 291 | var defaults = { | ||
504 | 292 | html_lng: null, | ||
505 | 293 | html_lat: null, | ||
506 | 294 | marker_icon: null, | ||
507 | 295 | markers: [], | ||
508 | 296 | html_addr: null, | ||
509 | 297 | mapOptions: { | ||
510 | 298 | zoom: 4, | ||
511 | 299 | center: new google.maps.LatLng(51.8211, 5.591), | ||
512 | 300 | mapTypeId: google.maps.MapTypeId.ROADMAP, | ||
513 | 301 | mapTypeControl: false | ||
514 | 302 | } | ||
515 | 303 | }; | ||
516 | 304 | options = $.extend(defaults, options); | ||
517 | 305 | |||
518 | 306 | function showPositionHTML(location) { | ||
519 | 307 | if (options.html_lng && options.html_lat) { | ||
520 | 308 | if (location.lat() && location.lng()) { | ||
521 | 309 | options.html_lat.val(location.lat()); | ||
522 | 310 | options.html_lng.val(location.lng()); | ||
523 | 311 | } | ||
524 | 312 | } | ||
525 | 313 | } | ||
526 | 314 | |||
527 | 315 | function setMarker(map, location) { | ||
528 | 316 | var marker = null; | ||
529 | 317 | |||
530 | 318 | if (options.markers.length) { | ||
531 | 319 | marker = options.markers[0]; | ||
532 | 320 | marker.setPosition(location); | ||
533 | 321 | marker.setAnimation(google.maps.Animation.DROP); | ||
534 | 322 | } else { | ||
535 | 323 | marker = new google.maps.Marker({ | ||
536 | 324 | map: map, | ||
537 | 325 | position: location, | ||
538 | 326 | draggable: true, | ||
539 | 327 | animation: google.maps.Animation.DROP | ||
540 | 328 | }); | ||
541 | 329 | if (options.marker_icon) { | ||
542 | 330 | marker.icon = options.marker_icon; | ||
543 | 331 | } | ||
544 | 332 | options.markers.push(marker); | ||
545 | 333 | google.maps.event.addListener(options.markers[0], 'mouseup', function () { | ||
546 | 334 | showPositionHTML(marker.getPosition()); | ||
547 | 335 | }); | ||
548 | 336 | } | ||
549 | 337 | |||
550 | 338 | map.setCenter(location); | ||
551 | 339 | showPositionHTML(marker.getPosition()); | ||
552 | 340 | } | ||
553 | 341 | |||
554 | 342 | return $(this).each(function (i, html_element) { | ||
555 | 343 | var map = new google.maps.Map($(html_element)[0], options.mapOptions), | ||
556 | 344 | geoCoder = new google.maps.Geocoder(), | ||
557 | 345 | location = null; | ||
558 | 346 | |||
559 | 347 | if (options.html_addr) { | ||
560 | 348 | options.html_addr.change(function () { | ||
561 | 349 | var address = []; | ||
562 | 350 | options.html_addr.each(function (i, item) { | ||
563 | 351 | address.push(item.value); | ||
564 | 352 | }); | ||
565 | 353 | |||
566 | 354 | geoCoder.geocode({address: address.join(' ')}, function (results, status) { | ||
567 | 355 | if (status === google.maps.GeocoderStatus.OK) { | ||
568 | 356 | setMarker(map, results[0].geometry.location); | ||
569 | 357 | } | ||
570 | 358 | }); | ||
571 | 359 | }); | ||
572 | 360 | } | ||
573 | 361 | google.maps.event.addListener(map, 'click', function (event) { | ||
574 | 362 | setMarker(map, event.latLng); | ||
575 | 363 | }); | ||
576 | 364 | |||
577 | 365 | if (options.html_lat.val() && options.html_lng.val()) { | ||
578 | 366 | location = new google.maps.LatLng(options.html_lat.val(), options.html_lng.val()); | ||
579 | 367 | setMarker(map, location); | ||
580 | 368 | } | ||
581 | 369 | }); | ||
582 | 370 | |||
583 | 371 | } | ||
584 | 372 | }); | ||
585 | 373 | }(jQuery)); | ||
586 | 0 | 374 | ||
587 | === modified file 'loco_directory/templates/events/global_event_detail.html' | |||
588 | --- loco_directory/templates/events/global_event_detail.html 2010-12-19 21:25:01 +0000 | |||
589 | +++ loco_directory/templates/events/global_event_detail.html 2011-02-17 17:57:17 +0000 | |||
590 | @@ -1,8 +1,19 @@ | |||
591 | 1 | {% extends "base.html" %} | 1 | {% extends "base.html" %} |
592 | 2 | {% load i18n %} | 2 | {% load i18n %} |
593 | 3 | 3 | ||
595 | 4 | {% block extrahead %}{{block.super}} | 4 | {% block extrahead %}{{ block.super }} |
596 | 5 | <link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}/css/twidenash.css" /> | 5 | <link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}/css/twidenash.css" /> |
597 | 6 | <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language={% trans 'en' %}®ion={% trans 'US' %}"></script> | ||
598 | 7 | <script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/src/markerclusterer_packed.js"></script> | ||
599 | 8 | <script type="text/javascript" src="{{MEDIA_URL}}js/jquery-ubuntu-maps.js"></script> | ||
600 | 9 | <script type="text/javascript"> | ||
601 | 10 | //<![CDATA[ | ||
602 | 11 | $(function(){ | ||
603 | 12 | $('#venue-map').showLocations({markers_url:'{% url global-event-locations global_event_id=global_event_object.id %}', | ||
604 | 13 | marker_icon: '{{ MEDIA_URL }}/img/marker.png'}); | ||
605 | 14 | }); | ||
606 | 15 | //]]> | ||
607 | 16 | </script> | ||
608 | 6 | {% endblock %} | 17 | {% endblock %} |
609 | 7 | 18 | ||
610 | 8 | {% block title %}{% trans global_event_object.name %} | {% trans "Ubuntu LoCo Team Directory" %} {% endblock %} | 19 | {% block title %}{% trans global_event_object.name %} | {% trans "Ubuntu LoCo Team Directory" %} {% endblock %} |
611 | 9 | 20 | ||
612 | === modified file 'loco_directory/templates/events/global_event_detail.inc.html' | |||
613 | --- loco_directory/templates/events/global_event_detail.inc.html 2011-02-03 14:26:00 +0000 | |||
614 | +++ loco_directory/templates/events/global_event_detail.inc.html 2011-02-17 17:57:17 +0000 | |||
615 | @@ -1,5 +1,6 @@ | |||
616 | 1 | {% load i18n %} | 1 | {% load i18n %} |
617 | 2 | {% block extrahead %}{{ block.super }} | 2 | {% block extrahead %}{{ block.super }} |
618 | 3 | |||
619 | 3 | {% if global_event_object.pictag %} | 4 | {% if global_event_object.pictag %} |
620 | 4 | <link rel="stylesheet" href="{{MEDIA_URL}}css/jquery.lightbox-0.5.css" type="text/css" media="screen" /> | 5 | <link rel="stylesheet" href="{{MEDIA_URL}}css/jquery.lightbox-0.5.css" type="text/css" media="screen" /> |
621 | 5 | <script type="text/javascript" src="{{MEDIA_URL}}js/jquery.lightbox-0.5.min.js"></script> | 6 | <script type="text/javascript" src="{{MEDIA_URL}}js/jquery.lightbox-0.5.min.js"></script> |
622 | @@ -97,11 +98,13 @@ | |||
623 | 97 | {% endif %} | 98 | {% endif %} |
624 | 98 | </article> | 99 | </article> |
625 | 99 | 100 | ||
627 | 100 | <article class="main-content"> | 101 | <article class="minor-content"> |
628 | 101 | <h3>{% trans "Details" %}</h3> | 102 | <h3>{% trans "Details" %}</h3> |
629 | 102 | {% include "events/global_event_detail_basic.inc.html" %} | 103 | {% include "events/global_event_detail_basic.inc.html" %} |
630 | 103 | </article> | 104 | </article> |
631 | 104 | 105 | ||
632 | 106 | <section id="venue-map" class="minor-content alone venue-map"></section> | ||
633 | 107 | |||
634 | 105 | <hr class="divide" /> | 108 | <hr class="divide" /> |
635 | 106 | 109 | ||
636 | 107 | {% if global_event_object.teamevent_set.all %} | 110 | {% if global_event_object.teamevent_set.all %} |
637 | 108 | 111 | ||
638 | === modified file 'loco_directory/templates/venues/venue_detail.html' | |||
639 | --- loco_directory/templates/venues/venue_detail.html 2010-11-20 17:25:50 +0000 | |||
640 | +++ loco_directory/templates/venues/venue_detail.html 2011-02-17 17:57:17 +0000 | |||
641 | @@ -4,10 +4,9 @@ | |||
642 | 4 | {% block title %}{% trans venue_object.name %} | {% trans "Ubuntu LoCo Team Directory" %} {% endblock %} | 4 | {% block title %}{% trans venue_object.name %} | {% trans "Ubuntu LoCo Team Directory" %} {% endblock %} |
643 | 5 | 5 | ||
644 | 6 | {% block extrahead %}{{block.super}} | 6 | {% block extrahead %}{{block.super}} |
649 | 7 | <script type="text/javascript" src="http://openlayers.org/api/OpenLayers.js"></script> | 7 | <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language={% trans 'en' %}®ion={% trans 'US' %}"></script> |
650 | 8 | <script src="http://maps.google.com/maps?file=api&v=2&key={{ google_api_key }}" type="text/javascript"></script> | 8 | <script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/src/markerclusterer_packed.js"></script> |
651 | 9 | <script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script> | 9 | <script type="text/javascript" src="{{ MEDIA_URL }}js/jquery-ubuntu-maps.js"></script> |
648 | 10 | <script type="text/javascript" src="{{MEDIA_URL}}/js/common.js"></script> | ||
652 | 11 | {% endblock %} | 10 | {% endblock %} |
653 | 12 | 11 | ||
654 | 13 | {% block sub_nav_links %} | 12 | {% block sub_nav_links %} |
655 | 14 | 13 | ||
656 | === modified file 'loco_directory/templates/venues/venue_detail.inc.html' | |||
657 | --- loco_directory/templates/venues/venue_detail.inc.html 2010-07-27 10:15:45 +0000 | |||
658 | +++ loco_directory/templates/venues/venue_detail.inc.html 2011-02-17 17:57:17 +0000 | |||
659 | @@ -4,18 +4,16 @@ | |||
660 | 4 | <p>{% include "venues/venue_detail_basic.inc.html" %}</p> | 4 | <p>{% include "venues/venue_detail_basic.inc.html" %}</p> |
661 | 5 | </article> | 5 | </article> |
662 | 6 | 6 | ||
663 | 7 | <article id="venue-map" class="" style="min-height: 300px; border: 0px;"> | ||
664 | 8 | {% if venue_object.longitude and venue_object.latitude %} | 7 | {% if venue_object.longitude and venue_object.latitude %} |
665 | 8 | <article class="minor-content alone venue-map" id="venue-map" class=""> | ||
666 | 9 | </article> | 9 | </article> |
667 | 10 | <script> | 10 | <script> |
676 | 11 | var lon = new Array(); | 11 | $(function(){ |
677 | 12 | var lat = new Array(); | 12 | $('#venue-map').showLocations({ |
678 | 13 | var htmltext = new Array(); | 13 | markers_list: [{ lat: {{ venue_object.latitude }}, lng: {{ venue_object.longitude }} }], |
679 | 14 | lon[0] = {{ venue_object.longitude }} | 14 | marker_icon: '{{ MEDIA_URL }}img/marker.png' |
680 | 15 | lat[0] = {{ venue_object.latitude }} | 15 | }); |
681 | 16 | htmltext[0] = "{{ venue_object.name }}" | 16 | }); |
674 | 17 | var select = new Boolean(false); | ||
675 | 18 | showmap('venue-map', select, lon, lat, htmltext) | ||
682 | 19 | </script> | 17 | </script> |
683 | 20 | {% endif %} | 18 | {% endif %} |
684 | 21 | 19 | ||
685 | 22 | 20 | ||
686 | === modified file 'loco_directory/templates/venues/venue_update.html' | |||
687 | --- loco_directory/templates/venues/venue_update.html 2010-11-20 17:25:50 +0000 | |||
688 | +++ loco_directory/templates/venues/venue_update.html 2011-02-17 17:57:17 +0000 | |||
689 | @@ -8,24 +8,18 @@ | |||
690 | 8 | {% endblock %} | 8 | {% endblock %} |
691 | 9 | 9 | ||
692 | 10 | {% block extrafooter %} | 10 | {% block extrafooter %} |
706 | 11 | <script type="text/javascript"><!-- | 11 | <script type="text/javascript"> |
707 | 12 | var lon = new Array(); | 12 | //<![CDATA[ |
708 | 13 | var lat = new Array(); | 13 | $(function(){ |
709 | 14 | var htmltext = new Array(); | 14 | $('#venue-map-selector').selectLocation({html_lng: $("#id_longitude"), |
710 | 15 | var select = new Boolean(true); | 15 | html_lat: $("#id_latitude"), |
711 | 16 | {% if venue_object %} | 16 | html_addr: $("#id_country, #id_spr, #id_city, #id_address"), |
712 | 17 | lon[0] = $("#id_longitude").val() | 17 | marker_icon: '{{ MEDIA_URL }}img/marker.png'}); |
700 | 18 | lat[0] = $("#id_latitude").val() | ||
701 | 19 | htmltext[0] = "{{ venue_object.name }}" | ||
702 | 20 | showmap('venue-map-selector', select, lon, lat, htmltext) | ||
703 | 21 | {% else %} | ||
704 | 22 | showmap('venue-map-selector', select) | ||
705 | 23 | {% endif %} | ||
713 | 24 | 18 | ||
718 | 25 | $(document).ready(function(){ | 19 | $('span[rel*=help]').colorTip({color:'orange'}); |
719 | 26 | $('span[rel*=help]').colorTip({color:'orange'}); | 20 | }); |
720 | 27 | }); | 21 | //]]> |
721 | 28 | --></script> | 22 | </script> |
722 | 29 | {% endblock %} | 23 | {% endblock %} |
723 | 30 | 24 | ||
724 | 31 | {% block content %} | 25 | {% block content %} |
725 | @@ -42,6 +36,6 @@ | |||
726 | 42 | </form> | 36 | </form> |
727 | 43 | </article> | 37 | </article> |
728 | 44 | 38 | ||
730 | 45 | <div id="venue-map-selector" title="{% trans "Select venue position" %}"> </div> | 39 | <section class="minor-content alone venue-map" id="venue-map-selector" title="{% trans "Select venue position" %}"> </section> |
731 | 46 | 40 | ||
732 | 47 | {% endblock %} | 41 | {% endblock %} |
733 | 48 | 42 | ||
734 | === modified file 'loco_directory/venues/forms.py' | |||
735 | --- loco_directory/venues/forms.py 2010-11-27 02:45:34 +0000 | |||
736 | +++ loco_directory/venues/forms.py 2011-02-17 17:57:17 +0000 | |||
737 | @@ -29,10 +29,9 @@ | |||
738 | 29 | '/media/css/colortip-1.0-jquery.css', | 29 | '/media/css/colortip-1.0-jquery.css', |
739 | 30 | )} | 30 | )} |
740 | 31 | js = ( | 31 | js = ( |
745 | 32 | 'http://openlayers.org/api/OpenLayers.js', | 32 | 'http://maps.google.com/maps/api/js?sensor=false&language=%(language)s®ion=%(region)s' % {'language': _('en'), 'region': _('US')}, |
746 | 33 | 'http://maps.google.com/maps?file=api&v=2&key='+google_api_key , | 33 | 'http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/src/markerclusterer_packed.js', |
747 | 34 | 'http://www.openstreetmap.org/openlayers/OpenStreetMap.js', | 34 | '/media/js/jquery-ubuntu-maps.js', |
744 | 35 | '/media/js/common.js', | ||
748 | 36 | '/media/js/colortip-1.0-jquery.js', | 35 | '/media/js/colortip-1.0-jquery.js', |
749 | 37 | ) | 36 | ) |
750 | 38 | 37 |
Pure awesome