Geo-6 | 22 Apr 12:19 2016
Picon

ol.format.WMSGetFeatureInfo : get wms layer name

Hi everyone,

 

I’am switching from Leaflet to OpenLayers3 and I’m quite impressed by OL3 !

 

I use « ol.format.WMSGetFeatureInfo().readFeatures() » to get features from WMS service and it worked very well but I do a GetFeatureInfo (GML) on one service with mutliple layers I’d like to know from wich wms layer my feature comes from.

 

Is it possible ?

 

Thanks a lot,

Have a great day.

 

Jonathan Beliën

GEO-6

 

_______________________________________________
Users mailing list
Users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Fernando Quadro | 7 Apr 20:14 2016
Picon
Gravatar

onImageLoadErrorColor in OL3

Hi ALL,

In OL2 was used the following line of code not to display the pink screen when geoserver did not run.

OpenLayers.Util.onImageLoadErrorColor = "transparent";

How to do this in OL3?

Thank you!

Best regards,
_______________________________________________
Users mailing list
Users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Derek Watling | 15 Mar 13:02 2016
Picon

Changing Kinetic setting in OL3

How does one access and work with the ol.interaction.DragPan kinetic property
in OL3?

I am wanting to toggel between the default kinetic behaviour / none.

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Changing-Kinetic-setting-in-OL3-tp5256443.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Dheeraj Chand | 6 Mar 18:11 2016
Gravatar

Slack, IRC?

IRC in freenode has become a graveyard! Did everything move to Slack? If so, how does one join?

Sent from my iPhone
_______________________________________________
Users mailing list
Users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
till.adams | 6 Mar 17:12 2016

Reminder - Call for Submissions FOSS4G2016

Hi OpenLayers-⁠Community,

not wanting to bother you, but also like to give everybody the chance to 
contribute to this years FOSS4G event! Hand in your talk, workshop, map 
or poster until 21st of March. You can find all relevant details and 
links here:
http://2016.foss4g.org/news-entry/call-for-submissions.html

If you have any question, don't hesitate contacting us.

Come and build bridges in Bonn,

Till
(Chair of FOSS4G 2016)

_______________________________________________
Users mailing list
Users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Derek Watling | 1 Mar 09:29 2016
Picon

Does OL3 have a click handler pixelTolerance setting?

In OpenLayers 2 one can specify a *pixelTolerance* setting in the Click
handler. If the map is moved by less than or equal to this value a click
event is also fired.

OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
    defaultHandlerOptions: {
        'pixelTolerance': 20,
        ...
    },
    ...
}

Question: Is there anything similar in OpenLayers 3?

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Does-OL3-have-a-click-handler-pixelTolerance-setting-tp5253535.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
jimmyfishbean | 25 Feb 16:51 2016
Picon

Using GeoWebCache with OpenLayers2 - Only certain zoom levels are hit

Hi All,

This is my first post so please bear with me and apologies if this is the
wrong group…

Versions: GeoServer 2.6.1 / GeoWebCache 1.6.1 / OpenLayers2 and 3

I have 2 applications, one a legacy OL2 website and the other a web
application utilising the OL3 library.  Three new raster base maps (250K,
50K and 25K) were added to GeoServer and cached using the caching interface
in GeoServer using the EPSG:27700 gridset (I reside in the UK and the
requirement is to display mapping data using this gridset / projection). 
The layers were all cached without any errors.  

The requirement is to display only a single base raster layer depending on
the current zoom / resolution.  The OL2 website currently only displays
vector shape files, whereas the OL3 application currently only displays the
base maps (this application was developed as a proof of concept to see if
the GeoWebCache could be used for loading tiled raster data).

The OL3 application works fine.  I am able to create an ol.tileGrid.TileGrid
object and set this on my ol.source.TileWMS object.  The origin property of
the TileGrid is set to the minX and minY values from the EPSG:27700 gridset
used to generate the tiles, and the resolutions property matches the
resolutions also from the EPSG:27700 gridset.  Basically, on start up I load
the 250K layer.  Then using the map moveend event, I detect if a different
base layer is to be loaded before unloading the current layer using
map.setTarget(null); and then calling the loadMap() again so the required
layer may be loaded and displayed.  The following is some of my OL3 code: 

function loadMap(baseLayerName) {
    // Resolutions of the EPSG:27700 gridset (Scales taken from GeoServer
Gridset screen and converted to resolutions using OL2
OpenLayers.Util.getResolutionFromScale() helper method)
    var resolutions = [
            2616.091417243591,
            1308.0457086217955,
            654.0228543108977,
            327.01142715544887,
            163.50571357772444,
            81.75285678886222,
            40.87642839443111,
            20.438214197215554,
            10.219107098607777,
            5.109553549303889,
            2.5547767746519443,
            1.2773883873259722,
            0.6386941936629861,
            0.31934709683149304,
            0.15967354841574652,
            0.07983677420787326
    ];

    // Create a mouse position control to relay the XY coordinates. Will use
the default map/view projection if the projection not specified.
    var mousePositionControl = new openLayers.control.MousePosition({
        coordinateFormat: openLayers.coordinate.createStringXY(0),
        projection: 'EPSG:27700',
        className: 'custom-mouse-position',
        target: document.getElementById('mouseposition'),
        undefinedHTML: '&nbsp;'
    });

    // "Direct integration with GeoServer WMS" is enabled in GeoServer
Caching Defaults, so no 
    // need to specify URL to point to GWC location. The TileGrid origin
matches the minX and minY 
    // values from the EPSG:27700 gridset
    var baseLayer = new openLayers.layer.Tile({
        source: new openLayers.source.TileWMS({
            url: 'http://X.X.X.X:8080/geoserver/wms',
            params: {
                'LAYERS': 'BaseLayerWorkspaceName:’ + baseLayerName,
                'TILED': true
            },
            // The TileGrid origin matches the minX and minY values from the
EPSG:27700 gridset
            tileGrid: new openLayers.tilegrid.TileGrid({
                origin: [1346.748175220855, 7097.996956234318],
                resolutions: resolutions
            })
        })
    });

    // Add the map control
    var map = new openLayers.Map({
        target: 'map',
        layers: [
            baseLayer
        ],
        controls: openLayers.control.defaults({
            attributionOptions: ({
                collapsible: false
            })
        }).extend([
            mousePositionControl
        ]),
        view: new openLayers.View({
            projection: 'EPSG:27700',
            resolutions: resolutions,
            center: [393674, 289141],
            zoom: (currentZoomLevel) ? currentZoomLevel : 0
        })
    });
}

When I attempt to implement the above using OL2, I am unable to do so with
success.  I cannot determine how to implement the TileGrid on my base layers
(I believe this is crucial), or find any resources on this.  When checking
the HTTP response headers using Chrome developer tools the following is
displayed:

Content-Disposition: inline;
filename=BASE_RASTER_25K_HEWMS:BASE_RASTER_25K_HEWMS
Content-Type: image/png
Date: Thu, 25 Feb 2016 15:13:14 GMT
geowebcache-cache-result: MISS
geowebcache-miss-reason: request does not align to grid(s) 'EPSG:27700'
Server: Apache-Coyote/1.1
Transfer-Encoding: chunked

As the subject to this post states, I am able to load from GeoWebCache
certain zoom level tiles, but most of the zoom levels report the above error
/ reason for failure and zero tiles get loaded from GeoWebCache.  The zoom
levels that work are:

•	Zoom 3 – 250K map.  The 250K map should be visible between zoom levels 0
and 5.
•	Zoom 5 – 50K map.  The 50K map should be visible only for zoom levels 6.
•	Zoom 6 – 25K map.  The 25K map should be visible between zoom levels 7 and
8.
•	The map loads at zoom level 9, meaning no base map is visible at start up. 
Only when the user zooms out to level 8 does the 25 K map load.

My gut feeling is the layer in OL2 needs to know the gridset it should use,
just as I create and add a layer using a TileGrid in OL3.  I have this
feeling because I encountered the same error messages when I provided origin
values other than the minX and minY

Some other things to note:
•	The OL2 application loads vector data on top of the base data.  Upon first
load, the map zooms to the extent of the vector data.
•	When the zoom level changes, unlike the OL3 application,
map.setTarget(null); is not called.  Instead,
this.map.setBaseLayer(baseLayers); is called to display the required base
layer and hide the others.  NOTE: The OL2 application creates instances of
each base layer upon startup and stores the layers in an array ready for use
when required.
•	No interaction occurs with the map or the viewport when zooming in or out
(i.e. the viewport bounds are not being changed by the user by expanding the
size of the map etc.).

The following is snippets of the OL2 code (not exact as refactored slightly
for this post – but I can assure you it runs!):

// Set the map extent for OpenLayers using the map boundary box
var mapExtent = new OpenLayers.Bounds(
    mapOptions.bounds.left, mapOptions.bounds.bottom,
    mapOptions.bounds.right, mapOptions.bounds.top
);

// Map options
var options = {
    controls: [],
    maxExtent: mapExtent,
    resolutions: [
        2616.091417243591,
        1308.0457086217955,
        654.0228543108977,
        327.01142715544887,
        163.50571357772444,
        81.75285678886222,
        40.87642839443111,
        20.438214197215554,
        10.219107098607777,
        5.109553549303889,
        2.5547767746519443,
        1.2773883873259722,
        0.6386941936629861,
        0.31934709683149304,
        0.15967354841574652,
        0.07983677420787326
    ],
    projection: 'EPSG:27700',
    units: 'm',
    theme: null
};

// Get the map
var map = new OpenLayers.Map(self.mapElementId, options);

// Draw the map layers (this will also call createBaseLayer() to create the
base layers and add to array)
self.drawMapLayers(mapOptions.layers);

// Get the element in which scale and location will be displayed
var scale = document.getElementById(self.options.scaleElementId);
var location = document.getElementById(self.options.locationElementId);

// Build up all the map controls
map.addControl(new OpenLayers.Control.PanZoomBar({
    position: new OpenLayers.Pixel(2, 2)
}));
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.ZoomBox());
map.addControl(new OpenLayers.Control.Attribution());
map.addControl(new OpenLayers.Control.ScaleLine());
map.addControl(new OpenLayers.Control.Scale(scale));
map.addControl(new OpenLayers.Control.MousePosition({ element: location,
numDigits: 2, emptyString: "" }));

map.zoomToExtent(mapExtent);

// Create the base layer
var createBaseLayer = function (title, rasterLayerName) {
    var layer = new OpenLayers.Layer.WMS(
        title,
        self.serviceUrl,
        {
            LAYERS: rasterLayerName,
            format: "image/png",
            tiled: true,
            tilesOrigin: map.maxExtent.left + ',' + map.maxExtent.bottom
            // NOTE: The tilesOrigin value is having no effect on loading
data from cache (i.e. the same zoom levels get hit and the same are missed)
            //tilesOrigin: 1346.748175220855 + ',' + 7097.996956234318 //
From gridset in GeoServer
        },
        {
            buffer: self.config.bufferSize,
            displayOutsideMaxExtent: true,
            isBaseLayer: true,
            yx: yx,
            attribution: self.config.copyright,
            tileOptions: { maxGetUrlLength: 2000 }
        }
    );

    // Add to base layers array
    self.baseLayers.push(layer);

    return layer;
};

Many thanks in advance.  

Regards,

Imran

--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Using-GeoWebCache-with-OpenLayers2-Only-certain-zoom-levels-are-hit-tp5252874.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Dheeraj Chand | 25 Feb 07:11 2016
Gravatar

Vector Layer disappears when maps pans/zooms

I'm working on switching from OpenLayers 2 to OpenLayers 3 and supplementing my reading of The Book of OpenLayers 3 by trying some things out on my own. There's a project that I'm building here that should be fairly simple: take form inputs and use them as parameters for building a vector layer. The interface works as intended, save for one problem.

Whenever I pan the map or zoom it, the vector layer seems to disappear. I can't for the life of me imagine what's going on. Anyone able to help me figure out what I can do to keep the layer in place?

Thanks!

Dheeraj

Code:

<!DOCTYPE html>
    <html>
    <head>
        <title>Chicago Data</title>
        <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.6.0/ol.css" type="text/css">
        <link rel="stylesheet" href="styles.css" type="text/css">
              rel='stylesheet' type='text/css'>
        <link href='https://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.6.0/ol.js"></script>
    
    </head>
    <body>
    <div class="container">
    
        <div class="row upper text-center"><!-- intro text -->
            <div class="col-md-12">
                <h1>Chicago Crimes Data Browser</h1>
                <h2>This is a simple interface to work with spatial data using <a href="http://www.openlayers.org">OpenLayers
                        3</a>.</h2>
                <hr/>
                <h3>Please select both a year and a crime category to visualise, then click on the map!</h3>
            </div>
        </div><!-- END UPPER -->
    
        <div class="row text-center"><!-- radio buttons top -->
            <div class="col-md-4 col-md-offset-2" id="year">
                <h5>Year</h5>
    
                <div class="radio-container">
                    <div class="radio">
                        <label>
                            <input type="radio" name="yearGroup" value="2016" checked>
                            2016
                        </label>
                    </div>
                    <div class="radio">
                        <label>
                            <input type="radio" name="yearGroup" value="2015">
                            2015
                        </label>
                    </div>
                </div>
            </div>
    
            <div class="col-md-4" id="category">
                <h5>Crime Category</h5>
    
                <div class="radio-container">
                    <div class="radio">
                        <label>
                            <input type="radio" name="categoryGroup" value="BURGLARY" checked>
                            Burglary
                        </label>
                    </div>
                    <div class="radio">
                        <label>
                            <input type="radio" name="categoryGroup" value="HOMICIDE">
                            Homicide
                        </label>
                    </div>
                </div>
            </div>
        </div><!-- end radio buttons bottom -->
    
        <div class="row text-center">
            <button class="btn btn-primary" type="submit" id="mapit">Map It</button>
        </div>
    
        <div class="row map"><!-- map section -->
            <div class="col-md-12" id="map"></div>
        </div><!-- end map -->
    
        <div id="tabular"><!-- table section -->
    
            <div class="row text-center">
                <div class="col-md-6 col-md-offset-3">
                    <h3 class="map-output">Crimes in Chicago 2015</h3>
                </div>
            </div>
    
            <div class="row text-center">
                <div class="col-md-2 col-md-offset-4">
                    <h4 class="grid-headline grid-headline-ward">Ward</h4>
                </div>
                <div class="col-md-2">
                    <h4 class="grid-headline grid-headline-count">Count</h4>
                </div>
            </div>
    
            <div class="row text-center">
                <div class="col-md-2 col-md-offset-4">
                    <p class="table-data">1</p>
                </div>
                <div class="col-md-2">
                    <p class="table-data">15</p>
                </div>
            </div>
    
            <div class="row text-center">
                <div class="col-md-2 col-md-offset-4">
                    <p class="table-data">2</p>
                </div>
                <div class="col-md-2">
                    <p class="table-data">34</p>
                </div>
            </div>
    
        </div><!-- end table section -->
    
        <div class="row"><!-- footer -->
            <div class="col-md-12 footer">
                <div id="footer"><p>This the footer div. Copyright <a href="http://www.clarityandrigour.com">Clarity and
                            Rigour 2016</a>. Please contact Dheeraj or John for more information.</p></div>
            </div>
        </div><!-- end footer -->
    
    </div><!--END CONTAINER -->
    <script>
        /* The following is material to be used in helper functions*/
    
    
        var styleCache = {}, // create styleCache variable
            defaultStyle = new ol.style.Style({
                stroke: new ol.style.Stroke({
                    color: [220, 220, 220, 1],
                    width: 1
                })
            }), // default uggeaux style
            color1 = [250, 250, 250, 1],
            color2 = [250, 128, 128, 1],
            color3 = [250, 64, 64, 1],
            color4 = [250, 0, 0, 1],
            color5 = [128, 0, 0, 1],
            colorLevels = {
                0: color1,
                0.2: color2,
                0.4: color3,
                0.6: color4,
                0.8: color5,
            };     // map the classfication level codes to a colour value, grouping them
        
        /* The following is helper functions that will be called by jQuery */
    
        function computeMinMaxFromProperty(total_data, property, year) {
            var geometries = (total_data.objects[year].geometries),
                incidents = _(geometries).map(function (g) {
                        if (property in g.properties) {
                            return g.properties[property];
                        }
                    })
                    .filter()
                    .value()
                    .sort(function (a, b) {
                        return a - b;
                    });
    
            var minMax = {
                min: _(incidents).min(),
                max: _(incidents).max()
            };
    
            return minMax;
        } // close function definition for compute minMax
    
    
        function buildStyle(feature, resolution, property, minMax) {
    
            var theMin = minMax['min'],
                theMax = minMax['max'],
                incidentsCount = feature.get(property);
    
            var classification = _(colorLevels).keys()
                .map(function (cl) {
                    if (((incidentsCount - theMin) / (theMax - theMin)) >= Number(cl)) {
                        return Number(cl);
                    }
                })
                .max()
    
    
            if (!incidentsCount || !colorLevels[classification]) {
                return [defaultStyle];
    
            }
    
            // check styleCache
    
            if (!styleCache[classification]) {
                styleCache[classification] = new ol.style.Style({
                    fill: new ol.style.Fill({
                        color: colorLevels[classification]
                    }),
                    stroke: defaultStyle.stroke
                });
    
                return [styleCache[classification]];
    
            }
        }// close buildstyle
    
        function buildLayer(property, minMax, filePath) {
    
            var vectorLayer = new ol.layer.Vector({
                source: new ol.source.Vector({
                    url: filePath,
                    format: new ol.format.TopoJSON()
                }),
                style: function (feat, res) {
                    return buildStyle(feat, res, property, minMax);
                }
            });
    
            map.addLayer(vectorLayer);
    
        } //close function definition for buildlayer
    
        /* The following is OL3 code to build the map*/
    
        // create base layer
    
        var osmLayer = new ol.layer.Tile({
            source: new ol.source.OSM()
        });
    
        // populate the map, centred on Chicago
    
        var map = new ol.Map({
            layers: [osmLayer],
            target: 'map',
            view: new ol.View({
                center: ol.proj.transform([-87.623177, 41.881832], 'EPSG:4326', 'EPSG:3857'),
                zoom: 10,
                minZoom: 10
            })
        });
    
    
        // now we are going to listen for changes to the radio buttons and build a layer accordingly
    
        $('#mapit').on('click', function (event) {
    
            var year = $("#year input:checked").val(),
                category = $("#category input:checked").val(),
                filePath = './topojsons/' + year + '.topo.json',
                styleCache = {};
    
    
            $.getJSON(filePath).then(function (data) {
                return computeMinMaxFromProperty(data, category, year);
            }).then(function (minMax) {
                buildLayer(category, minMax, filePath);
            })
        });
    
    </script>
    </body>
    </html>

_______________________________________________
Users mailing list
Users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Jan Hartmann | 13 Feb 18:36 2016
Picon

css layout for individual layer (openlayers 2)

Hi folks,

Is it possible to style individual layers of a map with css? I am trying 
to create a map slider effect as described here:

  https://books.google.nl/books?id=nokNCgAAQBAJ&pg=PA251&lpg=PA251&dq=www.theguardian.com+london-riots-before-afterphotographs&source=bl&ots=7KkOoDflUY&sig=PQ22hGTDV8PuZ9E83mv4qmnR9Qk&hl=en&sa=X&ved=0ahUKEwiNmuXdoPXKAhVCIQ8KHWcXA04Q6AEIPzAF#v=onepage&q=www.theguardian.com%20london-riots-before-afterphotographs&f=false

The example webpage from the Guardian does not work at the moment, but I 
have seen it functioning, and it is really a nice effect, very useful 
for maps. And it is really simple to implement for simple images, just a 
few lines of CSS. Javscript is only needed when you want to do it a bit 
fancier.  I just cannot get it working with OpenLayers 2. There is a 
property "div" for a map layer, but setting css styles on it it does 
only work with the "visibility" property. I cannot set borders, or  the 
properties I need for this functionality. Does anyone have any idea? The 
moment I can put a nice css border around a layer, my problem is solved.

Cheers,

Jan
Amsterdam
_______________________________________________
Users mailing list
Users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
pablo zader | 9 Feb 20:30 2016
Picon

Class diagram openlayers

Hi list
There is anyone class diagram to openlayers 2? 

it is possible to generate one from doygen?

Thanks in advanced

Pablo
_______________________________________________
Users mailing list
Users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Jim White | 9 Feb 00:42 2016
Picon
Picon

new to MapBox

Hi,

Can anyone show an example of how to style a Mapbox map with Mapbox studio?

I create a layer with OpenLayers.Layer.XYZ but just get a default style 
and don't know how to add styles.

Using OL2.

Thanks,
Jim

--

-- 
James B. White
Cary, NC
919-380-9615
http://whitecodingandmaps.com

_______________________________________________
Users mailing list
Users <at> lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Gmane