AnsweredAssumed Answered

Popup window doesn't work

Question asked by srajoli on Oct 30, 2014
Latest reply on Dec 8, 2014 by srajoli

I tried creating a popup window in map. When I run my program , it gets the basemap and the icons on the map , but not the popup window. Firebug throws this error

 

Error: Unable to draw graphic (null): Unable to complete operation.

 

...usePost,v=h.crossOrigin):A=!!h);g=e.mixin({},g);g._ssl&&(g.url=g.url.replace(/^h...

/3.11/ (line 871)

 

Error: Unable to draw graphic (null): Unable to complete operation.

 

...usePost,v=h.crossOrigin):A=!!h);g=e.mixin({},g);g._ssl&&(g.url=g.url.replace(/^h...

To solve this, I tried adding time between the layers, It didn't solve the problem. Below is my code. Please let me know, if I am making any mistake. Thanks!

<!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> Trees Location</title>
  <link rel="stylesheet" href="http://js.arcgis.com/3.11/dijit/themes/claro/claro.css">
  <link rel="stylesheet" href="http://js.arcgis.com/3.11/esri/css/esri.css">
  <script src="http://js.arcgis.com/3.11/"></script>
  <script>
  var map;
  require(["esri/config", "esri/map","esri/dijit/Popup",
  "dojo/dom-construct",
  "esri/dijit/PopupTemplate",
  "esri/layers/FeatureLayer",
  "esri/symbols/SimpleMarkerSymbol",
  "esri/tasks/GeometryService",
  "esri/layers/ArcGISDynamicMapServiceLayer",
  "esri/layers/ArcGISTiledMapServiceLayer",
  "esri/Color",
  "dojo/domReady!"],
  function (esriConfig, Map,Popup,domConstruct, PopupTemplate, FeatureLayer,SimpleMarkerSymbol, GeometryService, ArcGISDynamicMapServiceLayer, ArcGISTiledMapServiceLayer, Color ) {

esriConfig.defaults.geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
  var popupOptions = {
  markerSymbol: new SimpleMarkerSymbol("circle", 32, null,
  new Color([0, 0, 0, 0.25])),
  marginLeft: "20",
  marginTop: "20"
  };
  var popup = new Popup(popupOptions, domConstruct.create("div"));
  map = new Map("map", { 
  center: [-76.756, 40.241],
  zoom: 8,
  infoWindow: popup
  });
  var popupTemplate = new PopupTemplate({
  title: "{address}",
  fieldInfos: [
  {
  fieldName: "Tredonor",
  visible: true,
  label: "Type"
  },
  {
  fieldName: "Trespecies",
  visible: true,
  label: "Type"
  },
  {
  fieldName: "Trevariety",
  visible: true,
  label: "Type"
  }
  ]
  });

  var customBasemap = new ArcGISTiledMapServiceLayer(
  "");
  map.addLayer(customBasemap);
  /* setTimeout(function(){
  console.log("pausing a few seconds");
  map.addLayer(customBasemap);
},1000); */
  var treeLayer = new ArcGISDynamicMapServiceLayer(
  "");
  // map.addLayer(treeLayer);
  setTimeout(function(){
  console.log("pausing a few seconds");
  map.addLayer(treeLayer);
},1000);

var featureLayer = new FeatureLayer("",
  {
  infoTemplate: popupTemplate,
  outFields: ["Tredonor","Trespecies","Trevariety", "address"]
  });
  featureLayer.setDefinitionExpression("MEMORIAL != ''");
  map.addLayer(featureLayer);
});

</script>
</head>
<body class="claro">
<div align="center"><strong> Trees Listing   </strong><hr>
<i><a target="_self" href="listingtrees.html">Listing</a> | <a target="_self" href="locationtrees.html">Locations </a></i>
</div>
<br>
<div id="map" >
</div>
</body>
</html>

Outcomes