单击弹出窗口上的自定义按钮后在地图上显示图钉
Show pin on the map after clicking the custom button on the pop-up
我正在使用 ArcGIS JS API 4.0 和 angular。在弹出窗口中,我添加了自定义按钮更多详细信息,单击该按钮我想在地图上显示图钉。我没有找到很多在线示例来实现这一点,有人可以帮忙吗?
如果我没理解错的话,你的问题是在 action 方法中获取点击的位置。
如果是这样,您可以从 view.popup.location 中获取位置。这是一个点几何。有了它,您可以将新图形添加到图层或地图上。我没有与 AngularJS 合作过。所以无法为您提供样品。但是有了可用的位置详细信息,应该很容易找到添加图形的示例。
编辑:
这个例子比较合适。
https://developers.arcgis.com/javascript/latest/sample-code/get-started-graphics/index.html
感谢您的快速回复。你的回答真的很有帮助。我仍然发现很难存储弹出窗口位置,然后在单击弹出窗口上的自定义按钮时显示图钉。如果你知道,请告诉我。但是,我已经实施了我的解决方案,以便在单击地图上的要素后立即显示图钉。这是它的代码。
self.mapView.on("click", function (event) {
self.mapView.graphics.removeAll();
// I added this line to make sure the previous pin is removed if the new
//feature is clicked. If there is a better way to handle it, let me know.
// Create a symbol for drawing the point
var markerSymbol = new SimpleMarkerSymbol({
color: [226, 119, 40],
outline: { // autocasts as new SimpleLineSymbol()
color: [255, 255, 255],
width: 2
}
});
// Create a graphic and add the geometry and symbol to it
var pointGraphic = new Graphic({
geometry: event.mapPoint,
symbol: markerSymbol
});
self.mapView.graphics.addMany([pointGraphic]);
});
您可以在弹出窗口中回复 trigger-action
,然后使用已经提到的 view.popup.location
view.popup.on("trigger-action", function(evt){
if(evt.action.id === "more-details"){
// add graphic at view.popup.location
}
});
我正在使用 ArcGIS JS API 4.0 和 angular。在弹出窗口中,我添加了自定义按钮更多详细信息,单击该按钮我想在地图上显示图钉。我没有找到很多在线示例来实现这一点,有人可以帮忙吗?
如果我没理解错的话,你的问题是在 action 方法中获取点击的位置。
如果是这样,您可以从 view.popup.location 中获取位置。这是一个点几何。有了它,您可以将新图形添加到图层或地图上。我没有与 AngularJS 合作过。所以无法为您提供样品。但是有了可用的位置详细信息,应该很容易找到添加图形的示例。
编辑: 这个例子比较合适。 https://developers.arcgis.com/javascript/latest/sample-code/get-started-graphics/index.html
感谢您的快速回复。你的回答真的很有帮助。我仍然发现很难存储弹出窗口位置,然后在单击弹出窗口上的自定义按钮时显示图钉。如果你知道,请告诉我。但是,我已经实施了我的解决方案,以便在单击地图上的要素后立即显示图钉。这是它的代码。
self.mapView.on("click", function (event) {
self.mapView.graphics.removeAll();
// I added this line to make sure the previous pin is removed if the new
//feature is clicked. If there is a better way to handle it, let me know.
// Create a symbol for drawing the point
var markerSymbol = new SimpleMarkerSymbol({
color: [226, 119, 40],
outline: { // autocasts as new SimpleLineSymbol()
color: [255, 255, 255],
width: 2
}
});
// Create a graphic and add the geometry and symbol to it
var pointGraphic = new Graphic({
geometry: event.mapPoint,
symbol: markerSymbol
});
self.mapView.graphics.addMany([pointGraphic]);
});
您可以在弹出窗口中回复 trigger-action
,然后使用已经提到的 view.popup.location
view.popup.on("trigger-action", function(evt){
if(evt.action.id === "more-details"){
// add graphic at view.popup.location
}
});