commit property name changes back to client side state

This commit is contained in:
Sanj 2012-02-22 18:15:30 +05:30
parent 3307f42023
commit efbe97fae4

View File

@ -80,12 +80,15 @@ var API_BASE = "/1.0/",
stopsWithGeom.push(v); stopsWithGeom.push(v);
} }
}); });
stopsGeojson.features = stopsWithGeom; stopsGeojson.features = stopsWithGeom;
var currFeatures = jsonLayer.features; var currFeatures = jsonLayer.features;
jsonLayer.removeFeatures(currFeatures); jsonLayer.removeFeatures(currFeatures);
if (stopsWithGeom.length !== 0) {
jsonLayer.addFeatures(geojson_format.read(stopsGeojson)); jsonLayer.addFeatures(geojson_format.read(stopsGeojson));
var maxExtent = jsonLayer.getDataExtent(); var maxExtent = jsonLayer.getDataExtent();
map.zoomToExtent(maxExtent); map.zoomToExtent(maxExtent);
}
$target.append($stopsList); $target.append($stopsList);
// $target.data("hasList", true); // $target.data("hasList", true);
$target.data("loading", false); $target.data("loading", false);
@ -192,6 +195,8 @@ var API_BASE = "/1.0/",
var $lon_input = $('<input />').attr("type", "hidden").val(lon).attr("id", "lon").appendTo($form); var $lon_input = $('<input />').attr("type", "hidden").val(lon).attr("id", "lon").appendTo($form);
$form.submit(function(e) { $form.submit(function(e) {
e.preventDefault(); e.preventDefault();
var oldProps = $('.selectedStopItem').data("properties");
var geojson = { var geojson = {
'type': 'Feature', 'type': 'Feature',
'properties': { 'properties': {
@ -204,6 +209,8 @@ var API_BASE = "/1.0/",
'coordinates': [parseFloat($lon_input.val()), parseFloat($lat_input.val())] 'coordinates': [parseFloat($lon_input.val()), parseFloat($lat_input.val())]
} }
}; };
var props = $.extend(oldProps, geojson.properties);
$('.selectedStopItem').data("properties", props);
var geojsonString = JSON.stringify(geojson); var geojsonString = JSON.stringify(geojson);
//console.log(geojsonString); //console.log(geojsonString);
var url = API_BASE + "stop/" + stop.slug + "?srid=3857"; var url = API_BASE + "stop/" + stop.slug + "?srid=3857";