How to list columns of all layer on point clicked?

المشرف العام

Administrator
طاقم الإدارة
I was using geo-ext and it shows feature of all underlying layer on the point clicked. How to achieve this using openlayers 3. I am able to show feature of single layer on the point of click using below code. I have different columns on each layers.

Layer 1 - siteId,NameLayer 2 - waterResource,Place

I would like to make both the Layers visible in popup.

map.on('singleclick', function (evt) { console.log("Clicked"); var coord = evt.coordinate; var transformed_coordinate = ol.proj.transform(coord, "EPSG:900913", "EPSG:4326"); map.getLayers().forEach(function (lyr) { var source = layer.getSource(); var features = source.getFeatures(); console.log(features); });// Hide existing popup and reset it's offset popup.hide(); popup.setOffset([0, 0]); // Attempt to find a marker from the planningAppsLayer var feature = map.forEachFeatureAtPixel(evt.pixel, function (feature, layer) { return feature; }); if (feature) { var coord = feature.getGeometry().getCoordinates(); var props = feature.getProperties(); var info = "" + props.Site_Name + "

"; info += "" + props.locationtext + "

"; info += "Status: " + props.Status + " " + props.trick+ "

"; // Offset the popup so it points at the middle of the marker not the tip popup.setOffset([0, -22]); popup.show(coord, info); } else { console.log("into else"); var url = site_dwn_2g .getSource() .getGetFeatureInfoUrl( evt.coordinate, map.getView().getResolution(), map.getView().getProjection(), { 'INFO_FORMAT': 'application/json', 'propertyName': 'siteId,Name,trick' } ); reqwest({ url: url, type: 'json', }).then(function (data) { var feature = data.features[0]; var props = feature.properties; var info = "" + props.siteId + "

" + props.Site_Name + "

"; popup.show(evt.coordinate, info); }); } });

أكثر...
 
أعلى