Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

database populated for user markers

  • Loading branch information...
commit af0c9eef0415d46fd54ea804dfd4ddcf7835587f 1 parent d202c96
@substack authored
View
1  frontend/js/load.js
@@ -69,7 +69,6 @@ $(document).ready(function () {
name : "user_" + [0,0,0,0].map(function () {
return String(Math.floor(Math.random()*10));
}).join(""),
- description : "user marker",
mutable : true,
group_id : -1,
latitude : pt.lat(),
View
41 frontend/js/marker.js
@@ -63,25 +63,29 @@ function MarkerRow(map,marker) {
})
: $("<span>").text(marker.name)
;
- var latBox = $("<input>").attr({
- type : "hidden",
- name : "lat_marker_" + marker.name
- });
- var lonBox = $("<input>").attr({
- type : "hidden",
- name : "lon_marker_" + marker.name
- });
+ var latBox = $("<input>")
+ .attr("type","hidden")
+ .attr("name", "lat_marker_" + marker.name)
+ .val(marker.latitude)
+ ;
+ var lonBox = $("<input>")
+ .attr("type","hidden")
+ .attr("name", "lon_marker_" + marker.name)
+ .val(marker.longitude)
+ ;
+
+ var descTd = $("<td>");
+ marker.mutable
+ ? descTd.append(latBox,lonBox)
+ : descTd.text(marker.description)
+ ;
this.tr = $("<tr>").append(
$("<td>").append(checkbox),
$("<td>").append(nameOrBox),
- $("<td>").text(marker.description)
+ descTd
);
- if (marker.mutable) {
- this.tr.append(latBox,lonBox);
- }
-
this.hide = function () {
checkbox.attr("checked",false);
marker.hide();
@@ -94,7 +98,16 @@ function MarkerRow(map,marker) {
return this;
};
- if (! marker.mutable) {
+ if (marker.mutable) {
+ // drag a mutable marker, updating its lat/lon
+ google.maps.Event.addListener(
+ marker.gMarker, "dragend", function (pos) {
+ latBox.val(pos.lat());
+ lonBox.val(pos.lng());
+ }
+ );
+ }
+ else {
// drag an immutable marker, creating a mutable marker in its place
google.maps.Event.addListener(
marker.gMarker, "dragend",
View
12 frontend/lib/routes/jobs.py
@@ -68,10 +68,20 @@ def submit_job(request) :
if marker is not None
]
+ # new user markers to be created
user_marker_names = [ x.group(1) for x in
[ re.match(r'^user_marker_(.+)',y) for y in params.keys() ] if x
]
- user_markers = []
+ user_group = Group.get_by(id=-1) or Group(id=-1, name='user')
+
+ user_markers = [ Marker(
+ name = name,
+ description = '',
+ latitude = float(params['lat_marker_' + name]),
+ longitude = float(params['lon_marker_' + name]),
+ group = user_group,
+ user = True
+ ) for name in user_marker_names if params['marker_' + name] == 'on' ]
keys = """
time_step output_step sea_level bottom_friction earth_radius
Please sign in to comment.
Something went wrong with that request. Please try again.