We have an app that we built with Web App Builder along with some custom LayerList and Swipe widgets. One of the requirements we got this morning is that instead of showing a popup with a Hyperlinked URL when a user clicks on a feature in the web map, the customer just wants to skip the popup behavior altogether and click on features to open the URL.
I found a GeoNet Post by jai siva which gives me some good starting code:
- var map;
-
- require(["esri/map",
- "esri/layers/FeatureLayer",
- "esri/InfoTemplate",
- "dojo/on",
- "dojo/domReady!"],
- function(Map,FeatureLayer,InfoTemplate,on) {
- map = new Map("map", {
- basemap: "topo", //For full list of pre-defined basemaps, navigate to http://arcg.is/1JVo6Wd
- center: [0, 0] // longitude, latitude
- });
-
- var featureLayer = new FeatureLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3");
- map.addLayer(featureLayer);
-
- //Code for the specific URL to open in a new window
- featureLayer.on('click',function(e){
- var specific = e.graphic.attributes['SpecificAttribute']
- window.open("http://YourUrl.com/"+specific);
- });
- });
However, since this is going to be in a custom Web App Builder App, I'm having trouble finding the best place to drop the code. I've tried at init.js, simpleLoader.js and jimu.js/MapManager.js but haven't had any luck. Any ideas on the best place and/or way to accomplish this?