Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display multiple WFS layers with popup. #368

Open
seema30fresher opened this issue May 12, 2017 · 0 comments
Open

Display multiple WFS layers with popup. #368

seema30fresher opened this issue May 12, 2017 · 0 comments

Comments

@seema30fresher
Copy link

I want to display multiple WFS layers and display popup only for top layer. I wan't to disable all the base layer popup. Or if i wan't to display one features from all the layer (combine all layer features in one popup ).I have done some code but i don't understand how to add popup for one layer or popup for all layer but display only selected feature in one popup.This is my code ,

`document.addEventListener('DOMContentLoaded',function(){

var container = document.getElementById('popup');
var content = document.getElementById('popup-content');
var closer = document.getElementById('popup-closer');

var baselayer = new ol.layer.Vector({

title:'india ',
source:new ol.source.Vector({
url:"http://localhost:8088/geoserver/mapper/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=mapper:ind_adm1&maxFeatures=50&outputFormat=application%2Fjson",
format:new ol.format.GeoJSON()
})
}) ;

var layer = new ol.layer.Vector({
title:'india boubdry points',
source:new ol.source.Vector({
url:"http://localhost:8088/geoserver/abc/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=abc:india&maxFeatures=50&outputFormat=application%2Fjson",
format:new ol.format.GeoJSON()
})
}) ;

var overlay = new ol.Overlay(({
element: container
}));

var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source:new ol.source.OSM()
}),
baselayer,layer
],
overlays:[overlay],
view:new ol.View({
center:ol.proj.fromLonLat([78.3486781000,22.7622132000]),
maxZoom:50,
zoom:3
})
});

var select=new ol.interaction.Select();
select.on('select',function(e)
{
if(e.selected.length>0)
{
closer.addEventListener("click",function(evt)
{
container.style.display="none";
})
var cooordinates=e.mapBrowserEvent.coordinate
content.innerHTML='Bank:'+e.selected[0].H["fid"]+'
state:'+e.selected[0].H["st_name"]+'
District:'+e.selected[0].H["type_1"]+'';
overlay.setPosition(cooordinates);
container.style.display="block";
}
else
{
container.style.display="none";
}
});
map.addInteraction( select);
}); `

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant