Help with mobile popups

2410
2
10-17-2011 09:19 AM
GrantCarroll
New Contributor
Hi

I'm having some issues with mobile popups, I can get the popup to display, but the button to view extra info doesn't show and therefore I can't see the rest of the fields.

I have followed the sample of the web but it does't show how to create the template that shows the information. At the moment I'm downloading an rss feed of rain and river information and displaying the data on a map, i'd like to use the mobile popup to show graphs of the current levels of the various sites.

code for graphic
var p = getGeometryPoint(points[0],points[1]);
    var s = getPicSymbol(indicator,category);  
    var a = {"label":label,"curvalue":description,"hilltop":hilltop};
       var i  = new esri.dijit.PopupTemplate();
       i.setTitle("${curvalue}");
    i.setContent("${*}");
    
       var g = new esri.Graphic(p,s,a,i);
    
    glayer.add(g);


Code for adding the mobile popup to the map

popup = new esri.dijit.PopupMobile(null,dojo.create("div")); 
     
        var initialExtent = new esri.geometry.Extent({
          "xmin": 1518498,
          "ymin": 5307807,
          "xmax": 1774086,
          "ymax": 5487195,
          "spatialReference": {
            "wkid": 2193
          }
        });
        
        map = new esri.Map("map", {
          extent: initialExtent,
          infoWindow:popup
        });


Any ideas, help, samples of how to do this would be greatly appreciated.

Thanks
0 Kudos
2 Replies
KellyHutchins
Esri Frequent Contributor
The Feature Collection sample in the Feature Layer folder shows how to work with popups - including creating a template.

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/fl_featurecollection.html

Mobile Popups use the same approach you'll just need to add the mobile popup css reference and the dojo.require for mobile popup.

<link rel="stylesheet" type='text/css' href='http://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/esri/dijit/css/PopupMobile.css'/>


   dojo.require("esri.dijit.PopupMobile");


I think the part you may be missing from your code is where you associate features with the popup. Once you do this the navigation should appear. Here's a snippet that shows how to associate the currently clicked feature with the popup.
    //associate the features with the popup on click
        dojo.connect(featureLayer,"onClick",function(evt){
           map.infoWindow.setFeatures([evt.graphic]);
        });
0 Kudos
GrantCarroll
New Contributor
Magic, that did it, I hadn't associated the graphic on the click function. Thanks heaps for that, and links.

Cheers
0 Kudos