Within the created popup is a link with an ID (id ="request_17"). It is this ID we want to capture, when a user clicks on this......
<a href='#' onclick='showFeature(" + layerName + ".features[" + i + "]); return false;'>(show)</a>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9" /> <!--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> Full Map Layout </title> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/dojo/dijit/themes/claro/claro.css"> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.2/js/esri/css/esri.css" /> <script type="text/javascript" src="http://www.livefx.co.uk/clients/arcmap/jquery.min.js"></script> <style type="text/css"> html,body { height:100%; width:100%; margin:0; padding:0; } body { background-color:#777; overflow:hidden; font-family:"Trebuchet MS"; } #map { overflow:hidden; padding:0; } </style> <script type="text/javascript"> var dojoConfig = { parseOnLoad: true }; </script> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.2"> </script> <script type="text/javascript"> dojo.require("dijit.dijit"); // optimize: load dijit layer dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.map"); dojo.require("esri.IdentityManager"); dojo.require("esri.arcgis.utils"); var map; function init() { esri.config.defaults.io.proxyUrl = "/arcgisserver/apis/javascript/proxy/proxy.ashx"; //This service is for development and testing purposes only. We recommend that you create your own geometry service for use within your applications. esri.config.defaults.geometryService = new esri.tasks.GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); var urlObject = esri.urlToObject(document.location.href); var webmap = "d4caa59aec804e928da942f9a69d372b"; var bingMapsKey ="/*Please enter your own Bing Map key*/"; if (urlObject.query) { webmap = urlObject.query.webmap; bingMapsKey = urlObject.query.bingMapsKey; } var mapDeferred = esri.arcgis.utils.createMap(webmap, "map", { mapOptions: { slider: false, nav:false }, bingMapsKey: bingMapsKey, geometryServiceURL: "http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer" }); mapDeferred.addCallback(function(response) { map = response.map; //resize the map when the browser resizes //alert("dfdf"); dojo.connect(dijit.byId('map'), 'resize', map,map.resize); $(document).ready(jQueryReady); }); mapDeferred.addErrback(function(error) { console.log("Map creation failed: ", dojo.toJson(error)); }); } function resizeMap() { //resize the map when the browser resizes - view the 'Resizing and repositioning the map' section in //the following help topic for more details http://help.esri.com/EN/webapi/javascript/arcgis/help/jshelp_start.htm#jshelp/inside_guidelines.htm var resizeTimer; clearTimeout(resizeTimer); resizeTimer = setTimeout(function() { map.resize(); map.reposition(); }, 500); } function jQueryReady(){ $('#request_17').click(function() { alert("sdsfdfdfdgfg"); }); } $('#request_17').click(function() { alert("sdsfdfdfdgfg"); }); //show map on load dojo.addOnLoad(init); </script> </head> <body class="claro"> <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline'" style="width: 100%; height: 100%; margin: 0;"> <div id="map" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'center'"> <div id="bingLogo" style="position: absolute;bottom: 2px;left: 3px;display:none;z-index:49;"> <img src="images/bing_logo.png" border="0" /> </div> </div> </div> </body> </html>
<a href="javascript:void(0)" id="request_17">Add to Request list</a>
mapDeferred.then(function(response) { map = response.map; dojo.forEach(response.itemInfo.itemData.operationalLayers,function(layer){ //Do something with the layer here }); });
Ahhh, you're working with web maps - that's quite a crucial piece of information.So getting hold of the PopupTemplates for the layers would be through: var layers = response.itemInfo.itemData.operationalLayers;
var layers = response.itemInfo.itemData.operationalLayers;
...Either way, it looks like getting hold of the objects you need is pretty straightforward.
map.infoWindow.getSelectedFeature();
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.