goelajay

Popup not showing multiple entries

Discussion created by goelajay on Jan 20, 2013
I am using Uniquevalue rendered to show different icons with a popup showing details.  For some reason when there are 2 entries in the same lat long, the popup only shows the last entry instead of showing 1 of 2.  I must be doing something silly. 

Attaching the entire code and adding the JS code.

Thanks
dojo.require("esri.map");
dojo.require("esri.layers.FeatureLayer");
dojo.require("esri.dijit.Popup");
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");

var map = null;
var featureLayer = null;

function init() {
 
 var popupOptions = {
     'markerSymbol': new esri.symbol.SimpleMarkerSymbol('circle', 32, null, new dojo.Color([0, 0, 0, 0.25])),
     'marginLeft': '20',
     'marginTop': '20'
   };

 var popup = new esri.dijit.Popup(popupOptions, dojo.create("div"));
   
 map = new esri.Map("map", {
  extent: new esri.geometry.Extent({
   xmin: -13046970,
   ymin: 4036238,
   xmax: -13045355,
   ymax: 4036540,
   spatialReference: {
    wkid: 102100
   }
  }),
  infoWindow: popup
 });

 // for webmaps
 var arcgisURL = "http://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer"
 // 102100 
 var tiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer(arcgisURL);
 map.addLayer(tiledMapServiceLayer);
 createFeatureLayer();
}



function createFeatureLayer() {
 var fs = new esri.tasks.FeatureSet(jsonFS);   //jsonFS is coming from another static JS included in the HTML
 var fsCollect = new esri.tasks.FeatureSet();
 var featuresList = fs.features;
 
 var layerDefinition = {
  "displayFieldName": "EntityType",
  "geometryType": "esriGeometryPoint",
  "spatialReference": {
   "wkid": 102100
  },
  "fields": [{
   "name": "ObjectID",
   "alias": "ObjectID",
   "type": "esriFieldTypeOID"
   }, 
   {
   "name": "EntityType",
   "alias": "EntityType",
   "type": "esriFieldTypeString"
   }   
   ]
  }
 
 var featureCollection = {
  layerDefinition: layerDefinition,
  featureSet: fs
 };
 
 //alert(featureCollection.featureSet.features.length);
 //console.log(featureCollection);
 
 var popupTemplate = new esri.dijit.PopupTemplate({
   title: "{EntityTypeDisplay}",
         fieldInfos: [
                      {fieldName: "EntityTypeDisplay", visible: true, label:"Type"},
                      {fieldName: "Description", visible:true, label:"Description"}
                      ]
     });
 
 //esri.layers.FeatureLayer.MODE_ONDEMAND //MODE_SNAPSHOT
 featureLayer = new esri.layers.FeatureLayer(featureCollection,
   {
         mode: esri.layers.FeatureLayer.MODE_SELECTION,
         infoTemplate: popupTemplate,
         outFields: ['EntityTypeDisplay','Description']
   });
 var defaultSymbol = new esri.symbol.SimpleMarkerSymbol();
 
 
 var renderer = new esri.renderer.UniqueValueRenderer(defaultSymbol, "EntityType");
 
 //add symbol for each possible value
 var symbolpurplePartner = new esri.symbol.PictureMarkerSymbol("http://static.arcgis.com/images/Symbols/Shapes/PurplePin1LargeB.png", 32, 32).setOffset(0, 15);
 var symbolpurplePartners = new esri.symbol.PictureMarkerSymbol({"angle":0,"xoffset":0,"yoffset":10,"type":"esriPMS","url":"http://static.arcgis.com/images/Symbols/Shapes/PurplePin2LargeB.png","contentType":"image/png","width":24,"height":24});
 var symbolredDocument = new esri.symbol.PictureMarkerSymbol("http://static.arcgis.com/images/Symbols/Shapes/RedPin1LargeB.png", 32, 32).setOffset(0, 15);
 var symbolredDocuments = new esri.symbol.PictureMarkerSymbol({"angle":0,"xoffset":0,"yoffset":10,"type":"esriPMS","url":"http://static.arcgis.com/images/Symbols/Shapes/RedPin2LargeB.png","contentType":"image/png","width":24,"height":24}); 
 var symbolgreenProject = new esri.symbol.PictureMarkerSymbol({"angle":0,"xoffset":0,"yoffset":10,"type":"esriPMS","url":"http://static.arcgis.com/images/Symbols/Shapes/GreenPin1LargeB.png","contentType":"image/png","width":24,"height":24});
 var symbolgreenProjects = new esri.symbol.PictureMarkerSymbol({"angle":0,"xoffset":0,"yoffset":10,"type":"esriPMS","url":"http://static.arcgis.com/images/Symbols/Shapes/GreenPin2LargeB.png","contentType":"image/png","width":24,"height":24}); 
 
 //Find shapes here
 //http://help.arcgis.com/en/webapi/javascript/arcgis/samples/portal_symbols/index.html
 
 renderer.addValue("Partner", symbolpurplePartner);
 renderer.addValue("Partners", symbolpurplePartners); 
 renderer.addValue("Document", symbolredDocument);
 renderer.addValue("Documents", symbolredDocuments);
 renderer.addValue("Project", symbolgreenProject);
 renderer.addValue("Projects", symbolgreenProjects);
 featureLayer.setRenderer(renderer);
 
 map.addLayer(featureLayer);
 
    dojo.connect(featureLayer,"onClick",function(evt){
        map.infoWindow.setFeatures([evt.graphic]);
        console.log(evt.mapPoint.x + " " + evt.mapPoint.y);
     }); 

    /*
 dojo.connect(map, 'onClick', function (e) {
  console.log(e.mapPoint.x + " " + e.mapPoint.y);
   map.infoWindow.setTitle("Coordinates");
   map.infoWindow.setContent("lat/lon : " + e.mapPoint.y + ", " + e.mapPoint.x);
   map.infoWindow.show(e.screenPoint, map.getInfoWindowAnchor(e.screenPoint));
 });
*/
}

function getExtent() {
 document.write("MinX: " + map.extent.xmin + " MinY: " + map.extent.ymin + " MaxX: " + map.extent.xmax + " MaxY: " + map.extent.ymax);
}

dojo.addOnLoad(init);

Attachments

Outcomes