Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
          );       
      }
share|improve this question
    
Minor nit, but highly relevant... You've misspelled "tileOrigin" when you pass it to the second layer's constructor, and this parameter is required for meta-tiling. –  user19510 Jun 26 '13 at 22:13
add comment

1 Answer

Probably you can check on grouping label:

  1. http://docs.geoserver.org/latest/en/user/styling/sld-reference/labeling.html#grouping-features-group
  2. http://docs.geoserver.org/latest/en/user/styling/sld-reference/labeling.html#labelallgroup

Hopes that will help you.

Regards, Nas

share|improve this answer
    
Unfortunately I am still getting duplicate Labels. In layer preview on GeoServer,If I Switch the Tiling: option to Tiled, I can reproduce the Error. So I know I need to serve my WMS Layer as a single Tile I am just either confused on how to do that or why Meta-Tiling is not working... –  CrazySpatial Mar 12 '13 at 14:37
    
here an example from OpenLayers: openlayers.org/dev/examples/single-tile.html –  nasrulhazim Mar 13 '13 at 1:08
1  
Thank you Nasrulhazim for your help. I found a solution for anyone that is having this problem as well. Instead of meta tiling call I used {singleTile:true, ratio:1} –  CrazySpatial Mar 14 '13 at 22:38
    
no problems ;-) –  nasrulhazim Mar 15 '13 at 2:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.