//gfx is a graphic that comes from elsewhere... map.infoWindow.setTitle(gfx.getTitle()); map.infoWindow.setContent(gfx.getContent()); map.infoWindow.show(gfx.geometry);
highlightMarkerSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 22, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255,255,0]), 2), new Color([255,255,0,0.5])); var popup = new Popup({ fillSymbol: new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255,200,0]), 2), new Color([255,255,0,0.30])) , markerSymbol: highlightMarkerSymbol }, dojo.create("div")); map = new Map("mapDiv", { basemap: "topo", center: [-92.593, 38.5], infoWindow:popup, sliderPosition: "top-left", sliderStyle: "large", zoom: 7 });
var formatResults = arrayUtils.map(results, function(result){ var feature = result.feature; var layerName = result.layerName; feature.attributes.layerName = result.layerName; feature.setInfoTemplate(generateInfoTemplate); generateInfoTemplate.setTitle("Layer Information");//don't need a graphic, it's drawing from the infoWindow:popup in the map constructor return feature; }); if (formatResults.length === 0) { map.infoWindow.clearFeatures(); } else { map.infoWindow.setFeatures(formatResults); map.infoWindow.show(idPoint); } {/CODE] When I'm outside the map, in my grid, the items in that list aren't aware they are associated with a graphic, they're just data. But the data includes the objectID, so I'm running a query to get back to what the corresponding graphic is. This is a function that needs to work from one of two grids I have, so there's extra lines and incoming parameters here: //highlights the feature when the user selects from the grid function highlightFeatureFromGrid(event, dGrid, qTask) { app.map.graphics.clear(); app.map.infoWindow.hide(); var row = dGrid.row(event); var query = new Query(); var objid = [row.data.objectid]; query.where = "OBJECTID = " + objid; query.returnGeometry = true; query.outFields = ["*"]; query.outSpatialReference = spatialReference; qTask.execute(query, function (results) { var feature = results.features[0];//should only be on feature by that id in that layer var graphic; if (results.displayFieldName == 'VENDORID'){ feature.setInfoTemplate(venInfoTemplate); }else { feature.setInfoTemplate(offSatInfoTemplate); } app.map.centerAndZoom(feature.geometry, 12); graphic = new Graphic(feature.geometry, highlightMarkerSymbol,feature.attributes, feature.infoTemplate); app.map.graphics.add(graphic); app.map.infoWindow.setContent(feature.getContent()); app.map.infoWindow.setTitle(feature.getTitle()); app.map.infoWindow.show(feature.geometry); }); }
//results returned for (var index in results) { result = results[index]; attr = { "name": result.name, "lon": result.longitude, "lat": result.latitude }; template = { title: "${name}", body: infoWindowMinimizedFragment //HTML fragment }; pt = new Point(attr.lon, attr.lat); gfx = new Graphic(pt, symbols.resultSy, attr, new InfoTemplate(template.title, template.body)); resultsLayer.add(gfx); graphicsIndex[result.name] = gfx;
var gfx = graphicsIndex[event.target.innerHTML]; //map.selectGraphic(gfx); wishful thinking map.infoWindow.setTitle(gfx.getTitle()); map.infoWindow.setContent(gfx.getContent()); map.infoWindow.show(gfx.geometry);
map.selectGraphic(gfx); //not a real function
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.