client side stop saving fixed
This commit is contained in:
parent
7019c75d08
commit
cb22529db8
|
@ -88,7 +88,7 @@ def stop(request, slug):
|
||||||
srid = int(request.GET.get("srid", 4326))
|
srid = int(request.GET.get("srid", 4326))
|
||||||
if request.POST and request.POST.has_key('geojson'):
|
if request.POST and request.POST.has_key('geojson'):
|
||||||
if not request.user.is_staff:
|
if not request.user.is_staff:
|
||||||
return render_to_json_response({'error': 'No permission'})
|
return render_to_json_response({'errors': 'No permission'})
|
||||||
if not slug:
|
if not slug:
|
||||||
stop = Stop() #FIXME: should this return an error instead?
|
stop = Stop() #FIXME: should this return an error instead?
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -92,7 +92,7 @@ var API_BASE = "/1.0/",
|
||||||
stopsGeojson.features = stopsWithGeom;
|
stopsGeojson.features = stopsWithGeom;
|
||||||
var currFeatures = jsonLayer.features;
|
var currFeatures = jsonLayer.features;
|
||||||
jsonLayer.removeFeatures(currFeatures);
|
jsonLayer.removeFeatures(currFeatures);
|
||||||
console.log(stopsWithGeom);
|
//console.log(stopsWithGeom);
|
||||||
if (stopsWithGeom.length !== 0) {
|
if (stopsWithGeom.length !== 0) {
|
||||||
jsonLayer.addFeatures(geojson_format.read(stopsGeojson));
|
jsonLayer.addFeatures(geojson_format.read(stopsGeojson));
|
||||||
var maxExtent = jsonLayer.getDataExtent();
|
var maxExtent = jsonLayer.getDataExtent();
|
||||||
|
@ -129,6 +129,7 @@ var API_BASE = "/1.0/",
|
||||||
var $ul = $('<ul />')
|
var $ul = $('<ul />')
|
||||||
.addClass("stopsList")
|
.addClass("stopsList")
|
||||||
.click(function(e) {
|
.click(function(e) {
|
||||||
|
//e.stopPropagation();
|
||||||
var $target = $(e.target);
|
var $target = $(e.target);
|
||||||
if ($target.hasClass("selectedStop")) {
|
if ($target.hasClass("selectedStop")) {
|
||||||
return;
|
return;
|
||||||
|
@ -136,8 +137,11 @@ var API_BASE = "/1.0/",
|
||||||
// $('.selectedStop').removeClass("selectedStop");
|
// $('.selectedStop').removeClass("selectedStop");
|
||||||
// $target.addClass("selectedStop");
|
// $target.addClass("selectedStop");
|
||||||
var props = $target.data("properties");
|
var props = $target.data("properties");
|
||||||
|
//console.log($target, props);
|
||||||
var geom = $target.data("geometry");
|
var geom = $target.data("geometry");
|
||||||
var $form = getStopForm(props, geom);
|
var $form = getStopForm(props, geom);
|
||||||
|
//GLOB_FORM = $form;
|
||||||
|
//console.log($form);
|
||||||
var slug = $target.data("slug");
|
var slug = $target.data("slug");
|
||||||
if ($target.hasClass("has_point")) {
|
if ($target.hasClass("has_point")) {
|
||||||
selectStopOnMap(slug);
|
selectStopOnMap(slug);
|
||||||
|
@ -169,6 +173,7 @@ var API_BASE = "/1.0/",
|
||||||
function getStopForm(stop, geom) {
|
function getStopForm(stop, geom) {
|
||||||
// console.log(stop);
|
// console.log(stop);
|
||||||
// console.log(geom);
|
// console.log(geom);
|
||||||
|
//console.log(stop);
|
||||||
var lon = !$.isEmptyObject(geom) ? geom.coordinates[0] : '';
|
var lon = !$.isEmptyObject(geom) ? geom.coordinates[0] : '';
|
||||||
var lat = !$.isEmptyObject(geom) ? geom.coordinates[1] : '';
|
var lat = !$.isEmptyObject(geom) ? geom.coordinates[1] : '';
|
||||||
var $div = $('<div />');
|
var $div = $('<div />');
|
||||||
|
@ -334,7 +339,7 @@ var API_BASE = "/1.0/",
|
||||||
//alert("selected " + slug);
|
//alert("selected " + slug);
|
||||||
$('.selectedStop').removeClass("selectedStop");
|
$('.selectedStop').removeClass("selectedStop");
|
||||||
highlightStop(slug);
|
highlightStop(slug);
|
||||||
var stop = e.feature.attributes;
|
var stop = $('.selectedStop').data("properties");
|
||||||
var geom = {
|
var geom = {
|
||||||
'coordinates': [e.feature.geometry.x, e.feature.geometry.y]
|
'coordinates': [e.feature.geometry.x, e.feature.geometry.y]
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user