angular - Angular 页面中的 Esri 地图单击不再加载到经纬度?Object.b.locationToAddress 处为 null 的“toJSON”
问题描述
当前,当您单击 esri 地图时出现错误。该功能曾经有效。它发生在 locatorTask.locationToAddress(event.mapPoint).then(function (response) {
这里的代码:
mapView.when(function () {
mapView.popup.autoOpenEnabled = false;
mapView.on("click", function (event) {
searchWidget.clear();
mapView.popup.clear();
locatorTask
.locationToAddress(event.mapPoint)
.then(function (response) {
// If an address is successfully found, show it in the popup's content
mapView.popup.content = response.address;
var address = response.address;
showPopup(address, event.mapPoint);
})
.catch(function (error) {
// If the promise fails and no result is found, show a generic message
mapView.popup.content = "No address was found for this location";
showPopup("No address found.", event.mapPoint);
});
mapView.popup.visible = true;
});
})
感谢您的任何建议或帮助!
解决方案
您是否更改了 JavaScript API 版本?参数在版本 4.12 中已更改。
https://developers.arcgis.com/javascript/latest/guide/4.12/index.html
“将 locatorTask.locationToAddress() 参数从 (location, distance, requestOptions) 更改为现在接受 (params, requestOptions)。params 对象有两个属性:location 和 locationType。”
可以在此处找到新文档: https ://developers.arcgis.com/javascript/latest/api-reference/esri-tasks-Locator.html#locationToAddress
您的代码应该是:
locatorTask
.locationToAddress(location:{event.mapPoint})
.then(function (response) {
推荐阅读
- javascript - 如何捕获所有组并将其替换为组的重新格式化版本?
- assembly - ARM 汇编中的 LDR 和 EQU
- javascript - 在不考虑小时、分钟或秒的情况下确定今天的 unix 时间的捷径?
- angular - 如何在 Angular HTTP post 方法标头中插入用户输入?
- android - 按三星bixby按钮发送tcp包
- java - 将字符串值存储到 JSON 类型的字段中
- c++ - 在 DirectX 11 中从 GPU 读回顶点缓冲区(并获取顶点)
- node.js - readXlsxFile在节点js中乱序读取excel表
- python - 如何将 Telegram API 中的 contacts.getLocated() 与 Telethon 一起使用?
- javascript - 获取用户位置并显示数据