api.geocodeAddress(address, function (error, data) { $addressSearchStatus.fadeOut(100); if (error) { if (error.type === 'GeocodingError') { console.warn('We could not geocode the address: ' + address); } else { console.error('Unexpected error of type ' + error.type); console.error(error.message); } settings.address = ''; $addressSearchStatus.html('Sorry, we weren\'t able to find that address'); $addressSearchStatus.fadeIn(100).fadeOut(5000); return; } // Close the panel $toolPanel.panel('close'); // Record the address, for potential later use by the survey questions. // TODO: Try to avoid storing this as central state. settings.address = data.addressLine; mapView.goToLocation(data.coords, { zoom: 19 }); });
api.geocodeAddress(address, function (error, data) { if (error) { if (error.type === 'GeocodingError') { console.warn('We could not geocode the address: ' + address); } else { console.error('Unexpected error of type ' + error.type); console.error(error.message); } settings.address = ''; return; } mapView.goToLocation(data.coords, { zoom: 17 }); var selectedObject = { id: '', humanReadableName: address, centroid: { type: 'Point', coordinates: data.coords }, geometry: { type: 'Point', coordinates: data.coords } }; $.publish('selectionReady', [selectedObject]); });