Hey guys i am creating a web map and I am running into a little problem. I am serving two WMS layers from GeoServer to my OpenLayers script. For styling I am using SLD in GeoServer. The SLD script works fine in LayersPreview in GeoServer but on my Openlayers map when I zoom all the way in, my labels for my polygon double. I have read one or two issues with this and some have suggested using Meta-Tiling. My problem come in when trying to implement this option. No errors pop up but my results are the same. Below is my OpenLayers Code, am I doing something wrong or is there a error in my code?
function init() {
map = new OpenLayers.Map('map',{
controls:[
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.LayerSwitcher()
],
maxExtent:new OpenLayers.Bounds(
-128*156543.0339,
-128*156543.0339,
128*156543.0339,
128*156543.0339),
resolution:611.496,
units:'m',
projection:new OpenLayers.Projection('EPSG:900913'),
displayProjection:new OpenLayers.Projection("EPSG:4326"),
});
//Base Layers
arrayOSM = [
"http://otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.jpg",
"http://otile2.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.jpg",
"http://otile3.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.jpg",
"http://otile4.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.jpg"
];
arrayAerial = [
"http://oatile1.mqcdn.com/tiles/1.0.0/sat/${z}/${x}/${y}.jpg",
"http://oatile2.mqcdn.com/tiles/1.0.0/sat/${z}/${x}/${y}.jpg",
"http://oatile3.mqcdn.com/tiles/1.0.0/sat/${z}/${x}/${y}.jpg",
"http://oatile4.mqcdn.com/tiles/1.0.0/sat/${z}/${x}/${y}.jpg"
];
baseOSM = new OpenLayers.Layer.OSM("MapQuest-OSM Tiles", arrayOSM);
baseAerial = new OpenLayers.Layer.OSM("MapQuest Open Aerial Tiles",arrayAerial);
//Adding the 1st layer
Calv_Intersects = new OpenLayers.Layer.WMS("Calvert Intersections",
"http://vmhvsandbox.soon.curg.com:8080/geoserver/WinPS/wms?",
{
layers:'WorkingAPS:Calv_Intersections',
transparent:true,
format:'image/png'
},
{
isBaseLayer:false,
opacity:7
}
);
// Adding the second layer
Calv_Quads = new OpenLayers.Layer.WMS("Calvert Quads",
"http://vmhvsandbox.soon.ceng.com:8080/geoserver/WoPS/wms?",
{
layers:'WorkingAPS:Calv_Quads',
transparent:true,
format:'image/png',
tiled:true,
tilesOrgin:[map.maxExtent.left,map.maxExtent.bottom]
},
{
isBaseLayer:false,
opacity:45
}
);
//Adding all layers
map.addLayer(baseOSM);
map.addLayer(baseAerial);
map.addLayers([Calv_Intersects,Calv_Quads]);
//Setting zoom levels on both layers
map.events.on({ "zoomend": function (e) {
if (this.getZoom() > 16) {
Calv_Intersects.setVisibility(false);
Calv_Quads.setVisibility(true);
}
else {
Calv_Quads.setVisibility(false);
Calv_Intersects.setVisibility(true);
}
}
});
//Adding a pop up window
info = new OpenLayers.Control.WMSGetFeatureInfo({
url:'http://vmhvsandbox.soon.ceng.com:8080/geoserver/WPS/wms?',
title: 'Identify features by clicking',
queryVisible: true,
eventListeners: {
getfeatureinfo: function(event) {
map.addPopup(new OpenLayers.Popup.FramedCloud(
"c",
map.getLonLatFromPixel(event.xy),
null,
event.text,
null,
true
));
}
}
});
//Map Controls
map.addControl(info);
info.activate();
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(
new OpenLayers.LonLat(-76.631,39.083).transform(
new OpenLayers.Projection("EPSG:4326"),map.getProjectionObject()), 8
);
}