I have a JavasScript application consuming an ArcGIS Online Web Map. I want to open a default popup at a specific coordinate. Is there a way to simulate a mouse-click at that point, or a better alternative?
2 Answers
The map's default infoWindow
should actually be an instance of esri/dijit/Popup
, so the way to have it behave as if a user has just clicked on a given feature is to call its setFeatures()
method.
var point;
var query = new esri.tasks.Query();
// TODO: set query paramters
var deferred = featureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW);
deferred.then(function(results) {
// TODO: set point based on geometry of selected feature(s)
map.infoWindow.setFeatures(results.features);
map.infoWindow.show(point);
});
See the feature layer with popup sample and the Popup
API page for details.
If you're using the Javascript API you can use the show
method in the InfoWindowBase
class to display a popup at a given XY pair. See https://developers.arcgis.com/javascript/jsapi/infowindowbase-amd.html#show
-
Thanks Kevin, but the issue I'm having now is that I wanted the popup to have the format that I configured in ArcGIS Online. I have not figured out a way to do this through the JavaScript. Commented Jun 20, 2014 at 15:04
-
Ah that's getting out of my realm of experience. Have you seen the samples for the JavaScript API that bring in ArcGIS Online maps? If not, that could be a starting point. developers.arcgis.com/javascript/jssamples/ags_editor.html Commented Jun 20, 2014 at 15:21