Hello,
I am trying to make a basic web page. I have two feature layers, a polygon feature layer and then a point feature layer, both in the same mapping service:
mapping serviceA/0 = polygon
mapping serviceA/1 = point
in my app, which i am creating using Javascript API obviously, i want to have a different infowindow pop up for when a user clicks a point vs a polygon. I though i could just define the templates differently when i declare the feature layer, code below - but it ends up defaulting to the second info template. I know it can be done because i see it all the time, i just don't know how to do it with the javascript API. All of the samples and such just show how to work with info templates for one layer, not two. Can anyone help me?
var popup = new Popup({
fillSymbol: new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.25]))
}, domConstruct.create("div"));
map = new Map("map", {
sliderOrientation: "vertical",
center: [-122.15, 37.85],
zoom: 11,
basemap: "streets",
infoWindow: popup,
logo: false,
showLabels: true
});
// Polygon template
var template = new InfoTemplate();
template.setContent("Number of Main Breaks: ${OMGDB.%MainBreaks.GWO}");
template.setTitle("BMAP ${OMGDB.BMAP.BMAP}");
// Point template
var gwoTemplate = new InfoTemplate();
template.setContent("GWO Number: ${GWO}");
template.setTitle("BMAP: ${BMAP}");
// Polygon Feature Layer
var breaks = new FeatureLayer("http://localmapservice/MapServer/2", {
mode: FeatureLayer.MODE_ONDEMAND,
id: "breaks",
className: "text",
infoTemplate: template,
outFields: ["*"]
});
// Point Feature Layer
var breaksplot = new FeatureLayer("http:http://localmapservice/MapServer/0", {
mode: FeatureLayer.MODE_ONDEMAND,
id: "breaksplot",
infoTemplate: gwoTemplate,
outFields: ["GWO", "BMAP"]
});
i then tried adding the following lines hoping it would do something but alas, it did not:
dojo.connect(breaks, "onClick", function () {
//map.infoWindow.resize(100, 100)
breaks.infoTemplate = template;
});
dojo.connect(breaksplot, "onClick", function () {
breaksplot.infotempalte = gwoTemplate;
});
Hi Nicholas,
Based on the documentation it said that "Note: Only one info window is displayed on the map at a time." However you can take a look Nick Cameron 's reply on this post:Re: multiple infowindows on map (java script API)
He extended the Popup class and you can check his github repository: https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fgithub.com%2Fnickcam%2FPopupExtended
Hope this can help you.
Thank you Wendy! I missed this in my research.
whoops, meant Yue. Sorry, Wendy was talking to me when i wrote my response. Multi-tasking is not my strong suit!