var template = new esri.InfoTemplate(); template.setTitle("<b>HTML Popup Test</b>"); template.setContent("<iframe src='http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/StantonCountyKSLeases/MapServer/0/${OBJECTID}/htmlPopup?f=html' frameborder='0' width='100%' height='100%' style='width: 100%; height: 100%; display: block; padding: 0px; margin: 0px;'></iframe>"); var oilLayer = new esri.layers.FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/StantonCountyKSLeases/MapServer/0",{ infoTemplate:template });
<head> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.4"> </script> <link href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/dojo/dijit/themes/claro/claro.css" rel="stylesheet" type="text/css"> <link rel="stylesheet" type='text/css' href='http://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/esri/dijit/css/Popup.css' /> <title> popup test </title> <script type="text/javascript"> dojo.require("esri.map"); dojo.require("esri.layers.FeatureLayer"); function init() { var spatialRef = new esri.SpatialReference({ wkid: 102113 }); var startExtent = new esri.geometry.Extent(); startExtent.xmin = -3474427; startExtent.ymin = 3213361; startExtent.xmax = 3409296; startExtent.ymax = 11057509; startExtent.SpatialReference = spatialRef; var map = new esri.Map("mapDiv", { extent: startExtent }); map.setExtent(startExtent); var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"); map.addLayer(basemap); var biotemplate = new esri.InfoTemplate(); biotemplate.setTitle("<b>HTML Popup Test</b>"); /*biotemplate.setContent("<iframe src='http://discomap.eea.europa.eu/ArcGIS/rest/services/Bio/LifeProjects_Dyna_WGS84/MapServer/0/${OBJECTID}/htmlPopup?f=html' frameborder='0' width='100%' height='100%' style='width: 100%; height: 100%; display: block; padding: 0px; margin: 0px;'></iframe>");*/ biotemplate.setContent(updatePopup); var bioLayer = new esri.layers.FeatureLayer("http://discomap.eea.europa.eu/ArcGIS/rest/services/Bio/LifeProjects_Dyna_LAEA/MapServer/0", { infoTemplate: biotemplate }); map.addLayer(bioLayer); var oiltemplate = new esri.InfoTemplate(); oiltemplate.setTitle("<b>HTML Popup Test</b>"); oiltemplate.setContent("<iframe src='http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/StantonCountyKSLeases/MapServer/0/${OBJECTID}/htmlPopup?f=html' frameborder='0' width='100%' height='100%' style='width: 100%; height: 100%; display: block; padding: 0px; margin: 0px;'></iframe>"); var oilLayer = new esri.layers.FeatureLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/StantonCountyKSLeases/MapServer/0", { infoTemplate: oiltemplate }); map.addLayer(oilLayer); map.infoWindow.resize(600, 300); } function updatePopup(graphic){ var deferred = new dojo.Deferred(); var url = graphic.getLayer().url + "/" + graphic.attributes.OBJECTID + "/htmlPopup?f=json"; esri.request({ url: url, content:url.query, callbackParamName: "callback", load: function(response) { //esriServerHTMLPopupTypeAsURL deferred.callback( "<iframe src='" + response.content +"' frameborder='0' width='100%' height='100%' style='width: 100%; height: 100%; display: block; padding: 0px; margin: 0px;'></iframe>"); }, error: function(error) { deferred.errback("Error occurred while generating profile"); } }); return deferred; return requestHandle; } dojo.addOnLoad(init); </script> </head> <body class="claro"> <div id="head"> </div> <div id="mapDiv" style="width:100%; height:90%; border:1px solid #000;"> </div> </body>
//Set templates up for sustainability infowindows sustaintemplate = new esri.InfoTemplate(); //Set infoTemplates for sustainability layers setSustainInfoTemplates(); function setSustainInfoTemplates() { for (var j = 0; j < featureLayers.length; j++) { featureLayers.setInfoTemplate(sustaintemplate); } } } function mapReady(map) { map.infoWindow.resize(400, 430); dojo.connect(map, "onClick", executeIdentifyTask); identifyTask1 = new esri.tasks.IdentifyTask("http://falcon.camplan.uga.edu/OUAGISSERVER/rest/services/UGA_SustainBase/MapServer"); identifyParams1 = new esri.tasks.IdentifyParameters(); identifyParams1.tolerance = 5; identifyParams1.returnGeometry = true; identifyParams1.layerIds = [0,1,2,3,4,5,6,7,8,9,10,12,14]; identifyParams1.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL; identifyParams1.width = map.width; identifyParams1.height = map.height; //resize the map when the browser resizes dojo.connect(dijit.byId('map'), 'resize', map, map.resize); } function executeIdentifyTask(evt) { //create identify task and setup parameters identifyParams1.geometry = evt.mapPoint; identifyParams1.mapExtent = map.extent; var deferred1 = identifyTask1.execute(identifyParams1); deferred1.addCallback(function (response) { // response is an array of identify result objects // Let's return an array of features. return dojo.map(response, function (result) { var feature = result.feature; feature.attributes.layerName = result.layerName; switch(result.layerName){ case 'UGA Buildings': alert("UGA Buildings!!"); var template = new esri.InfoTemplate(); feature.setInfoTemplate(template); break; case 'Road Names': alert("Road Names!!"); var template = new esri.InfoTemplate(); feature.setInfoTemplate(template); break; case 'Cisterns_Point': alert("Cisterns!!"); var sustaintemplate = new esri.InfoTemplate(); sustaintemplate.setTitle("<b>UGA Sustainability Info</b>"); sustaintemplate.setContent(updatePopup); feature.setInfoTemplate(sustaintemplate); break; case 'DinHall_Point': alert("DinHall!!"); sustaintemplate.setTitle("<b>UGA Sustainability Info</b>"); sustaintemplate.setContent(updatePopup); break; case 'GrRoofs_Point': alert("Grroofs!!"); sustaintemplate.setTitle("<b>UGA Sustainability Info</b>"); sustaintemplate.setContent(updatePopup); break; case 'HistBuild_Point': alert("Histbuild!!"); sustaintemplate.setTitle("<b>UGA Sustainability Info</b>"); sustaintemplate.setContent(updatePopup); break; case 'LEED_Point': alert("LEED!!"); sustaintemplate.setTitle("<b>UGA Sustainability Info</b>"); sustaintemplate.setContent(updatePopup); break; case 'Prod_Point': alert("Prod!!"); sustaintemplate.setTitle("<b>UGA Sustainability Info</b>"); sustaintemplate.setContent(updatePopup); break; case 'Retail_Point': alert("Retail!!"); sustaintemplate.setTitle("<b>UGA Sustainability Info</b>"); sustaintemplate.setContent(updatePopup); break; case 'StrRest_Point': alert("Strrest!!"); sustaintemplate.setTitle("<b>UGA Sustainability Info</b>"); sustaintemplate.setContent(updatePopup); break; case 'SusBuild_Point': alert("Susbuild!!"); sustaintemplate.setTitle("<b>UGA Sustainability Info</b>"); sustaintemplate.setContent(updatePopup); break; case 'RainGardens': alert("Raingar!!"); sustaintemplate.setTitle("<b>UGA Sustainability Info</b>"); sustaintemplate.setContent(updatePopup); break; case 'PorPave_Point': alert("PorPave!!"); sustaintemplate.setTitle("<b>UGA Sustainability Info</b>"); sustaintemplate.setContent(updatePopup); break; } return feature; }); }); // InfoWindow expects an array of features from each deferred // object that you pass. If the response from the task execution // above is not an array of features, then you need to add a callback // like the one above to post-process the response and return an // array of features. map.infoWindow.setFeatures([deferred1]); map.infoWindow.show(evt.mapPoint); } function updatePopup(graphic) { var deferred = new dojo.Deferred(); var url = graphic.getLayer().url + "/" + graphic.attributes.OBJECTID + "/htmlPopup?f=json"; esri.request({ url: url, content: url.query, callbackParamName: "callback", load: function (response) { //esriServerHTMLPopupTypeAsURL deferred.callback("<iframe src='" + response.content + "' frameborder='0' width='100%' height='100%' style='width: 100%; height: 100%; display: block; padding: 0px; margin: 0px;'></iframe>"); }, error: function (error) { deferred.errback("Error occurred while generating profile"); } }); console.log(url); return deferred; return requestHandle; }
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.