通过 OpenCage 服务器提供地理编码(geocoding)功能。
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
url |
Resource | string | OpenCage 服务器的端点(endpoint)。 | ||||||
apiKey |
string | OpenCage 的 API Key。 | ||||||
params |
object |
optional
包含以下属性的对象(参见 https://opencagedata.com/api#forward-opt):
|
||||||
options.add_request |
number | optional 当设置为 1 时,各种请求参数会被添加到响应中,以便于调试。 | ||||||
options.bounds |
string | optional 为地理编码器提供查询所在区域的提示。 | ||||||
options.countrycode |
string | optional 将结果限制为指定的一个或多个国家(依据 ISO 3166-1 Alpha 2 标准定义)。 | ||||||
options.jsonp |
string | optional 使用函数名包裹返回的 JSON。 | ||||||
options.language |
string | optional IETF 格式的语言代码。 | ||||||
options.limit |
number | optional 我们应返回的最大结果数量。 | ||||||
options.min_confidence |
number | optional 1 到 10 之间的整数。仅返回置信度至少达到该值的结果。 | ||||||
options.no_annotations |
number | optional 当设置为 1 时,结果将不包含注释(annotations)。 | ||||||
options.no_dedupe |
number | optional 当设置为 1 时,结果将不会被去重。 | ||||||
options.no_record |
number | optional 当设置为 1 时,查询内容不会被记录。 | ||||||
options.pretty |
number | optional 当设置为 1 时,结果会被“pretty”打印以便阅读。对调试很有用。 | ||||||
options.proximity |
string | optional 为地理编码器提供提示,使结果偏向于更靠近指定位置的结果(例如:41.40139,2.12870)。 |
Example:
// Configure a Viewer to use the OpenCage Geocoder
const viewer = new Cesium.Viewer('cesiumContainer', {
geocoder: new Cesium.OpenCageGeocoderService('https://api.opencagedata.com/geocode/v1/', '<API key>')
});
Members
readonly credit : Credit|undefined
获取在执行地理编码后显示的 credit(版权信息)。通常这用于为地理编码服务署名。
为自定义地理编码而传递给 OpenCage 的可选参数。
readonly url : Resource
用于访问 OpenCage 端点的 Resource。
Methods
geocode(query) → Promise.<Array.<GeocoderService.Result>>
| Name | Type | Description |
|---|---|---|
query |
string | 要发送给地理编码服务的查询。 |
