0

As it's indicated in the title, I want to know how to force an OpenLayers Markers layer to draw on top, and having labeled layers beneath. I have an OSM baseMap and one selectable layer that contain labels.

So I followed this link, and I created a new js file, but in vain. I spent 2 days trying to do it without any result, can anyone help me please?

Community
  • 1
  • 1
  • From the information you have provided, it is impossible to tell what is going on, a jsFiddle or full code sample to reproduce the problem would be required. Once comment though, in general markers are deprecated, and you should use a normal Feature.Vector with graphics instead of markers and then the layers will be drawn in the order to which they are added to the map. – John Powell Aug 29 '14 at 07:23

1 Answers1

0

Thanks for your responce. So the code I used is the following :

for the BaseMap and the Labeled Layer (it's also selectable)

             map = new OpenLayers.Map('map',{controls: [new OpenLayers.Control.Navigation(),
                         new OpenLayers.Control.PanZoomBar(),
                         new OpenLayers.Control.LayerSwitcher({'ascending':false}),
                         new OpenLayers.Control.ScaleLine(),

                         new OpenLayers.Control.MousePosition(),
                         new OpenLayers.Control.OverviewMap(),
                         new OpenLayers.Control.KeyboardDefaults()], 
             numZoomLevels: 30, 
             projection: mercator,
             displayProjection: geographic,
             units: "m",
             extent: indoor
             });

    var style = new OpenLayers.StyleMap({

        "default": new OpenLayers.Style({
                    fillColor: "#ff9544",
                    fillOpacity: 0.9,
                    strokeColor: "#fc5411",
                    strokeWidth: 1,
                    //strokeDashstyle: "dash",
                     label: "${name}",
                   // labelAlign: "cc",
                    fontColor: "#0000",
                    fontOpacity: 1,
                    fontFamily: "sans-serif",


                   })})

               var layerLocalisation = new OpenLayers.Layer.Vector("Localisations",{isBaseLayer: false,visibility : true});                

var layer = new OpenLayers.Layer.Vector("Bati", {
                   strategies: [new OpenLayers.Strategy.Fixed()],
                   styleMap: style,
                   protocol: new OpenLayers.Protocol.HTTP({
                   url: "data/gml/bati.xml",
                   format: new OpenLayers.Format.GML(),
                   projection: mercator
               })
           });

  var gmap = new OpenLayers.Layer.Google(
               "Google Streets", // the default
           {numZoomLevels: 30, visibility: false}
        );                     

  map.addLayers([gmap,layer,layerLocalisation]);

In a function related to button in my HTML page (function that add a Marker after typing logitude and latitude) :

   function locate()
        {
             var coox = document.getElementById("idlong").value;
             //alert(coox);
             var cooy = document.getElementById("idlat").value;


              var coo1 =  new OpenLayers.LonLat(coox, cooy).transform(geographic,mercator);

              var point1 =  new OpenLayers.Geometry.Point(coo1.lon,coo1.lat);

              var featurePoint1 = new OpenLayers.Feature.Vector(
               point1,
              { description: 'info' },
               { externalGraphic: 'OpenLayers/img/marker-gold.png', graphicHeight: 25, graphicWidth: 21, graphicXOffset: -12, graphicYOffset: -25 }
              );

              layerLocalisation.addFeatures([featurePoint1]);             
              // map.addLayers([vectorLayer1]);
              map.setCenter(coo1,18);           
      }

So the Marker is shown but, it is under the selectabale labeled layer, I hope that I am so clear,