0

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 2

2

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.

1

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

2
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.