And example would be typing in "KBOS". There's a TX radio station with those call letters, and the airport in Boston has that as its ICAO code. Both are returned from the search, so it would be nice to have a selection drop down from the text box. Google Maps has this kind of functionality in their search box.
--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
The following code, NominatimGeocoderService.js will do the trick. Simply edit the 'url' variable to the base of your Nominatim service
define([
'Cesium/Core/defaultValue',
'Cesium/Core/defined',
'Cesium/Core/defineProperties',
'Cesium/Core/DeveloperError',
'Cesium/Core/loadJsonp',
'Cesium/Core/Rectangle'
], function (
defaultValue,
defined,
defineProperties,
DeveloperError,
loadJsonp,
Rectangle) {
var url = 'http://mynominatim.org/nominatim/search.php';
/**
* Provides geocoding through Nominatim.
* @alias NominatimGeocoderService
* @constructor
*
* @param {Object} options Object with the following properties:
* @param {String} options.scene The scene
*/
function NominatimGeocoderService(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
}
defineProperties(NominatimGeocoderService.prototype, {
/**
* The URL endpoint for the Nominatim geocoder service
* @type {String}
* @memberof {NominatimGeocoderService.prototype}
* @readonly
*/
url: {
get: function () {
return url;
}
}
});
/**
* @function
*
* @param {String} query The query to be sent to the geocoder service
* @returns {Promise<GeocoderResult[]>}
*/
NominatimGeocoderService.prototype.geocode = function (query) {
//>>includeStart('debug', pragmas.debug);
if (!defined(query)) {
throw new DeveloperError('query must be defined');
}
//>>includeEnd('debug');
var promise = loadJsonp(url, {
parameters: {
format: 'json',
q: query
},
callbackParameterName: 'json_callback'
});
return promise.then(function (results) {
if (results.length === 0) {
return [];
}
return results.map(function (resource) {
var bbox = resource.boundingbox;
var south = bbox[0];
var north = bbox[1];
var west = bbox[2];
var east = bbox[3];
return {
displayName: resource.display_name,
destination: Rectangle.fromDegrees(west, south, east, north)
};
});
});
};
return NominatimGeocoderService;
});
Using it in a simple viewer can then be accomplished with:
var nominatimGeocoderService = new NominatimGeocoderService();
var viewer = new Viewer('cesiumContainer',
{
baseLayerPicker: true,
geocoder: nominatimGeocoderService
}
);
Xander
--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
Sandcastle nominatim search does not work on my system: Chrome 64bits: Version 61.0.3163.100 (Official Build) (64-bit)
Also in my 'normal' 1.38 Cesium the Geocoder does not work.....
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+unsubscribe@googlegroups.com.