我正在使用Esri Javascript API 4.5
当地图加载时,我从外部源获取点坐标,然后使用Graphic
类在地图上绘制它并为该图形指定PopupTemplate
。
图形已在地图上成功绘制。但是为了查看弹出模板,我需要点击图形。
是否可以在将图形添加到地图时触发图形的点击事件,以便弹出模板自动显示?
require([
"esri/PopupTemplate",
"esri/Graphic",
.
.
.
.
"dojo/domReady!"
],
function (
PopupTemplate, Graphic, ....) {
var point = {
type: "point",
x: <some x>,
y: <some y>
};
var symbol = {
type: "picture-marker",
url: "/euf/assets/nl/images/red-pin.png",
width: "30px",
height: "30px"
};
var template = new PopupTemplate({
title: "New Title",
content: "New Content"
});
var graphic = new Graphic({
geometry: point,
symbol: symbol,
popupTemplate: template
});
view.graphics.add(graphic); // this works as I can see the marker on page
// now, how do I trigger its click event here?
});
答案 0 :(得分:2)
您应该使用view.popup.open并传递属性location
和features
:
view.popup.open({
location: point,
features: [graphic]
});
答案 1 :(得分:0)
这是我用多边形的infoWindow做的一个例子。
wq1 := i.wq1