var mapBook = new FeatureLayer("[Webservice]", { mode: FeatureLayer.MODE_SNAPSHOT }); map.addLayer(mapBook); mapBook.on("click", function(evt) { var url = [Need to pass attribute value here]; window.open(url); });
Solved! Go to Solution.
mapBook.on("click", function(evt) { var url = evt.graphic.attributes.<field name>; window.open(url); });
mapBook.on("click", function(evt) { var url = evt.graphic.attributes.<field name>; window.open(url); });
var mapBook = new FeatureLayer("[Webservice]", { mode: FeatureLayer.MODE_SNAPSHOT, outFields: ["*"] });
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--The viewport meta tag is used to improve the presentation and behavior of the samples on iOS devices--> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"> <title>FeatureLayer On Demand</title> <link rel="stylesheet" href="http://js.arcgis.com/3.9/js/dojo/dijit/themes/claro/claro.css"> <link rel="stylesheet" href="http://js.arcgis.com/3.9/js/esri/css/esri.css"> <style> html, body, #mapDiv { padding: 0; margin: 0; height: 100%; } </style> <script src="http://js.arcgis.com/3.9/"></script> <script> var map; require(["esri/map", "esri/layers/FeatureLayer", "dojo/parser", "dojo/domReady!"], function(Map, FeatureLayer, parser) { parser.parse(); map = new Map("mapDiv", { basemap : "national-geographic", center : [-81.792107, 26.150807], zoom : 9 }); var parcels = new FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/0", { mode : FeatureLayer.MODE_SNAPSHOT, outFields : ["*"] }); map.addLayer(parcels); parcels.on("click", function(evt) { var url = evt.graphic.attributes.areaname; console.log("url = ", url); }); }); </script> </head> <body class="claro"> <div id="mapDiv"></div> </body> </html>