[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.
This commit is contained in:
Rufus Pollock
2012-05-27 02:48:54 +01:00
parent c6d4116cba
commit ea6f051aba

View File

@@ -345,8 +345,11 @@ my.Map = Backbone.View.extend({
if (this.state.get('geomField')){ if (this.state.get('geomField')){
var value = doc.get(this.state.get('geomField')); var value = doc.get(this.state.get('geomField'));
if (typeof(value) === 'string'){ if (typeof(value) === 'string'){
// We have a GeoJSON string representation // We *may* have a GeoJSON string representation
return $.parseJSON(value); try {
return $.parseJSON(value);
} catch(e) {
}
} else { } else {
// We assume that the contents of the field are a valid GeoJSON object // We assume that the contents of the field are a valid GeoJSON object
return value; return value;