From efbe97fae47520cf244a5a3e7237a34d19bd4b2e Mon Sep 17 00:00:00 2001 From: Sanj Date: Wed, 22 Feb 2012 18:15:30 +0530 Subject: [PATCH] commit property name changes back to client side state --- chaloBEST/static/js/editstops.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/chaloBEST/static/js/editstops.js b/chaloBEST/static/js/editstops.js index c796c5b..be057ef 100644 --- a/chaloBEST/static/js/editstops.js +++ b/chaloBEST/static/js/editstops.js @@ -80,12 +80,15 @@ var API_BASE = "/1.0/", stopsWithGeom.push(v); } }); + stopsGeojson.features = stopsWithGeom; var currFeatures = jsonLayer.features; jsonLayer.removeFeatures(currFeatures); - jsonLayer.addFeatures(geojson_format.read(stopsGeojson)); - var maxExtent = jsonLayer.getDataExtent(); - map.zoomToExtent(maxExtent); + if (stopsWithGeom.length !== 0) { + jsonLayer.addFeatures(geojson_format.read(stopsGeojson)); + var maxExtent = jsonLayer.getDataExtent(); + map.zoomToExtent(maxExtent); + } $target.append($stopsList); // $target.data("hasList", true); $target.data("loading", false); @@ -192,6 +195,8 @@ var API_BASE = "/1.0/", var $lon_input = $('').attr("type", "hidden").val(lon).attr("id", "lon").appendTo($form); $form.submit(function(e) { e.preventDefault(); + var oldProps = $('.selectedStopItem').data("properties"); + var geojson = { 'type': 'Feature', 'properties': { @@ -204,6 +209,8 @@ var API_BASE = "/1.0/", 'coordinates': [parseFloat($lon_input.val()), parseFloat($lat_input.val())] } }; + var props = $.extend(oldProps, geojson.properties); + $('.selectedStopItem').data("properties", props); var geojsonString = JSON.stringify(geojson); //console.log(geojsonString); var url = API_BASE + "stop/" + stop.slug + "?srid=3857";