From ea6f051aba4634dbab901fca6cc80fb8ad91caf9 Mon Sep 17 00:00:00 2001 From: Rufus Pollock Date: Sun, 27 May 2012 02:48:54 +0100 Subject: [PATCH] [view/map,bugfix][xs]: be more cautious about assuming a location field actually gains geodata (and geojson specifically). * At present giving data with e.g. { location: 'New York'} would lead the view to crash on a JSON parsing error. --- src/view-map.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/view-map.js b/src/view-map.js index 412ab2c7..8e622a0a 100644 --- a/src/view-map.js +++ b/src/view-map.js @@ -345,8 +345,11 @@ my.Map = Backbone.View.extend({ if (this.state.get('geomField')){ var value = doc.get(this.state.get('geomField')); if (typeof(value) === 'string'){ - // We have a GeoJSON string representation - return $.parseJSON(value); + // We *may* have a GeoJSON string representation + try { + return $.parseJSON(value); + } catch(e) { + } } else { // We assume that the contents of the field are a valid GeoJSON object return value;