【发布时间】:2022-01-03 03:31:21
【问题描述】:
目前,在我将位置详细信息(纬度、经度等)传递给 Esri 地图后,我的 Esri 地图会在 Esri 地图上将位置显示为精确点。
所以,现在我想要的是当用户点击特定的精确点时,我想显示一个弹出模板并显示一个包含其地址、经度、纬度等的表格。 我想动态迭代我已经拥有的位置对象数组(locationData)并设置popupTemplate标题,内容, feildInfo、fieldName 等
这是我所做的,我现在收到以下控制台错误。
const popUpTemplate = new PopupTemplate({
title: '',
content: locationData.map((d,i)=>(
[
{
type:"fields",
fieldInfos: [
{
fieldName: d.address,
label: "Address"
},
{
fieldName: d.latitude,
label: "Latitude",
format: {
places: 2
}
},
{
fieldName: d.longitude,
label: "Longitude",
format: {
places: 2
}
}
]
},
new CustomContent({
outFields: ["*"],
creator: (event) => {
const a = document.createElement("a");
// a.href = event.graphic.attributes.url;
a.target = "_blank";
// a.innerText = event.graphic.attributes.url;
return a;
}
})
]
))
});
const dataFeedLayer = new FeatureLayer({
source: horizonData.map((d,i)=>(
{
geometry: new Point({
longitude: d.longitude,
latitude: d.latitude
}),
attributes: {
ObjectID: i,
...d
}
}
)),
fields: [
{
name: "ObjectID",
alias: "ObjectID",
type: "oid"
},
{
name: "name",
alias: "Name",
type: "string"
},
{
name: "addrs",
alias: "addrs",
type: "string"
},
{
name: "url",
alias: "url",
type: "string"
},
{
name: "lat",
alias: "Latitude",
type: "double"
},
{
name: "lon",
alias: "Longitude",
type: "double"
}
],
objectIdField: 'ObjectID',
geometryType: "point",
renderer: renderer,
popupTemplate: popUpTemplate,
});
webmap.add(dataFeedLayer);
[esri.core.Accessor] Accessor#set 无效的属性值,值需要是“esri.popup.content.MediaContent”、“esri.popup.content.CustomContent”、“esri.popup.content”之一。 TextContent'、'esri.popup.content.AttachmentsContent'、'esri.popup.content.FieldsContent' 或可以自动投射的普通对象(具有 .type = 'media'、'custom'、'text'、'attachments' , '字段')
关于如何解决这个问题的任何想法。提前致谢。
【问题讨论】:
标签: javascript esri arcgis-js-api esri-maps esri-arc-engine