Popup for graphics layer with external data.

266
0
03-12-2012 08:48 AM
RyanMuller
New Contributor II
I'm plotting points on my basemap by pulling data into a JsonRestStore and then looping over each item in the store and adding a simplemarkersymbol onto the graphics layer. I want to display a simple info window when a symbol is clicked. Currently I'm not even populating the info window attributes from the store. I'm just setting them statically. I'm using the onItem event of the jsonreststore to run ShowCrimeResult which is converts the X,Y coordinates in my store to actual coordinates and adds them to the graphics layer.



  var queryCrimes = function (city) {
    var spillmanStore = new dojox.data.JsonRestStore({
      target:"/SpillmanService/SpillmanService.svc/GetIncidentsByCity",
      allowNoTrailingSlash:true
    });

    var showCrimeResult = function (item, request) {
      var xcoord = parseFloat(spillmanStore.getValue(item, "X"));
      var ycoord = parseFloat(spillmanStore.getValue(item, "Y"));
      var pt = new esri.geometry.Point(xcoord, ycoord, myMap.spatialReference);
      myMap.graphics.add(new esri.Graphic(

      esri.geometry.geographicToWebMercator(pt),
        new esri.symbol.SimpleMarkerSymbol(),
       { 'title': 'Test Title', 'content': 'Here is some content' }, // attributes
       new esri.InfoTemplate('${title}', '${content}')
      ));
    };

    spillmanStore.fetch({query:{CITY:city}, queryOptions:{cache:true}, onItem:showCrimeResult});

  }


However I can't get an infowindow to display when clicking on the graphics objects that are added to the map. The graphics display when I run the query but they are non-interactive. Do I need to connect to the onclick event of myMap.graphics?
0 Kudos
0 Replies