Created
March 11, 2013 00:22
-
-
Save dbouwman/5131145 to your computer and use it in GitHub Desktop.
Geocode results handler - if we get one match back, it just raises the event, if we get any other number, we send the results to a collection, and
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
geocodeResultsHandler:function(data,status,jqXHR){ | |
console.log('Got Geocode Results...'); | |
console.dir(data); | |
//get the count returned | |
var foundCount = data.locations.length; | |
if(foundCount === 1){ | |
var loc = data.locations[0]; | |
//hide the ui and zoom to the location | |
//create a simple point Object | |
var pt = { | |
x:loc.feature.geometry.x, | |
y:loc.feature.geometry.y | |
} | |
Viewer.vent.trigger('Map:CenterAt',pt); | |
this.hideSearch(); | |
}else{ | |
//show the list | |
//convert the locations into a flatter collection of objects | |
var locs = []; | |
_.each(data.locations,function(item){ | |
locs.push({ | |
name:item.name, | |
x: item.feature.geometry.x, | |
y: item.feature.geometry.y | |
}); | |
}); | |
//create a collection from these geezers | |
this.locationsCollection = new LocationCollection(locs); | |
//throw them into an collection view | |
var locationListView = new LocationsListView({collection:this.locationsCollection}); | |
//show the collection view in the geocode-results-region | |
//if locs is an empty array, the collectionview will show the | |
this.layout.resultsRegion.show(locationListView); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment