Tag Info

New answers tagged

0

Accordind to the doc you need to parse the event.features and build your text for the popup: info = new OpenLayers.Control.WMSGetFeatureInfo({ url: 'http://localhost:8080/geoserver/wms', title: 'Identify features by clicking', queryVisible: true, eventListeners: { getfeatureinfo: function(event) { var txt = ""; ...


-1

For my QGIS 2.4 this is located in: Web > OpenLayers plugin


1

You have a couple of issues. 1). Those bounds do not look correct. If you look at spatial ref.org for that projection, you will see that the projected bounds are: 2490547.1867, 5440321.7879, 2609576.6008, 5958700.0208. Your input, 363273 is way outside of these bounds. Using Postgis, select st_astext(st_transform(st_setsrid(st_makepoint(363273, 5770864), ...


2

Feature creation can be kind of tricky in OpenLayers 3. There aren't any official examples for ol.source.Vector layers, most of them are working with GeoJSON, or some other data exchange format. I have managed to create a working fiddle. Let me explain some of the key aspects of achieving your task. var layerLines = new ol.layer.Vector({ source: new ...


1

After searching a little deeper, I just remembered that vector layer in OL is drawn on canvas. So it's easier to work with since HTML5 canvas has the 'color-blend' property called globalCompositeOperation. //First get the DOM Element of the layer var div = document.getElementById(buffer_layer.id); //Then get the canvas element; //it returns an array, so ...


1

You can't turn the layers in a layer group on and off independently. If your client needs to turn layers off then you need to request them separately in OpenLayers.


2

Can you try this (change GeoJSON to the format you want to load.): vector_format = new OpenLayers.Format.GeoJSON({ 'internalProjection': new OpenLayers.Projection("EPSG:31466"), 'externalProjection': new OpenLayers.Projection("EPSG:3857") }); result = vector_format.read(newFeatures); vectorLayer.addFeatures(result); This worked for me.


0

You can use an attribute form the feature to determine if the feature should be visible. I haven't tested it, but i think this should work: $.each(pois.features, function (index, feature) { if ( feature.attributes.description == 'UV-foto' ) feature.style.display = 'none'; });


1

You have two choices Solution 1: You can change the reference to proj4js. OpenLayers 2.x default support is with Proj4js 1.1 whereas you use 2.x. <!doctype html> <html lang="en"> <head> <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/proj4js/1.1.0/proj4js-compressed.min.js"></script> <script ...


0

You need to change the css tag olControlAttribution in style.css or override it in a style tag in the <head> element. This tag looks like: .olControlAttribution { font-size: smaller; right: 3px; bottom: 4.5em; position: absolute; display: block; } so changing bottom: 4.5em to something like bottom: 1px ought to do it. The source of ...


1

One thing you can do if you have base layers with different resolutions is to detect for the layer in the changebaselayer callback and then reset the map's resolutions array, and redraw the panzoombar control, so it can only zoom to the new base layer's resolutions. map.events.register("changebaselayer", this, function (obj) { if (obj.layer.name == ...


0

It seems you didn't search before asking or I misunderstand. You can already have the answer at this question. Edit due to comment Ok, WPS can be a bit annoying. So, another way is to call GetCapabilities if you use a WMS. You can convert the XML result to JSON and extract layer extent. See this official example illustrating the concept.


2

In OlpenLayers 3 you can just initialize your view with the desired zoom constraints: var map = new ol.Map({ target: 'map', // ... view: new ol.View({ maxZoom: 8, minZoom: 6, zoom: 7 }) });


0

I want to give feedback on my project evolution and how i solved my problem of editing WMS features, both attributes and geometry. Using WMSGetFeatureInfo and asking for information in JSON format i can store all the atributtes in a object. Using a form in the popup I then edit the values and send them to a JSP page that i created inside Geoserver webapps ...


2

This question was asked on Twitter recently https://twitter.com/RemiBovard/status/525028570780139520 If you follow the answer, at the moment, integrating layer switcher in the core is not the priority but there is an available component at https://github.com/walkermatt/ol3-layerswitcher You can also take a look on "The book of OpenLayers" samples (by ...


0

Check that the url created by OpenLayers in your app matches the one from the 'Layer Preview' in GeoServer using the developer tools in your browser. Check the network tab.


0

I assume you're asking about Open Layers 3? I use Jquery (or straight js) and setup a mouse event on the viewport. This will let you identify what feature is clicked. I also add a custom attribute to the feature to identify if its polygon,icon,etc. var iconFeature = new ol.Feature({YOUR FEATURE PROPERTIES}) iconFeature.set('automodify',true); ...


0

I solved it. The problem is the variable 'google', which overwrites something as it can be imagined. I call it 'google_layer', now it works - no, it still does not work but at least it does not bring any JS error.


1

Just see this official demo example http://openlayers.org/en/v3.0.0/examples/wms-image.html Some others WMS samples are available. You will just need to change ServerType to mapserver (link for reference) Edit for completing with solution Without proj4js, you can always use the recipe from this other official example Declare an object ol.proj.Projection ...


0

You can't using only OpenLayers 3 (I would be happy to learn how if not). The image you get in the demo is the one you get by exporting the map Canvas element in the DOM. Your pop-up is part of the DOM so outside the Canvas hence the exported image. Providing HTML element in the Canvas does not seem possible ...


0

Try using a z-index property as described on http://www.w3schools.com/cssref/pr_pos_z-index.asp for example #coordexterne { ... z-index: 999; ... } See fiddle http://jsfiddle.net/nzcktv9e/ , play with the z value and click run again to see the effect


1

As nobody provided an answer and meanwhile I created a solution, I will post it as an answer. The main problem was, that I was thinking in a cartesian plane, while the projection is based on a sphere. It worked in some situations, while failed in other cases. The task is to filter out these cases. I changed the averaging formula a little to add more ...


1

For future seekers of ol knowledge, I found the answer using the SelectControl control, which has a hash of attributes including two booleans that were pertinent to my problem: 'box' and 'multiple'. The docs are here: http://dev.openlayers.org/releases/OpenLayers2.10/doc/apidocs/files/OpenLayers/Control/SelectFeature-js.html#OpenLayers.Control.SelectFeature ...


1

Sure you can. Its as easy as loading the map. See this example: http://dev.openlayers.org/examples/osm-google.html Code: (Place this after the OpenLayers map) var gmap = new OpenLayers.Layer.Google("Google Streets"); map.addLayer(gmap); and load the folowing javascript: <script ...


2

You will need to add a new interaction. Assuming that... this.mapRaster = ol.Map This should work this.mapRaster.on('singleclick',function(e){ var iconFeature = new ol.Feature({ geometry: new ol.geom.Point(e.coordinate), }); iconFeature.setStyle(_self.iconStyle); _self.rasterVectorSource.addFeatures([iconFeature]); Make the ...


1

If security is not an issue but you only want to load data within the current viewport. You can also look at OpenLayers BBOX strategy.


0

Yes, it is definitely possible. QGis has a QTiles plugin, which uses gdal2tiles under the hood, AFAIK. Then you can use leaflet/openlayers to read your tiles from the created directory structure.


0

It is normal, that OpenLayers registers click events to map instances when constructed. You can try to block them with the stopPropagation() method or prevent them with the preventDefault() method. If you use OpenLayers 2, you can try to unregister them manually, but you have to know which events you want to unregister ...


0

What I finally found out that helped: f.feature.geometry = new OpenLayers.Geometry.MultiPolygon(f.feature.geometry);


0

You perhaps fail because you are trying to insert a polygon into WFS layer which is of type multipolygon. I would try the "multi" option from http://dev.openlayers.org/docs/files/OpenLayers/Control/DrawFeature-js.html multi {Boolean} Cast features to multi-part geometries before passing to the layer. Default is false.


2

I didn't play with it but I remember seeing Bjørn Sandvik from Thematic Mapping playing with Three.js and WMS. The recipe is available on this blog post.


1

This is covered in THIS answer which asks how to return a tile for a Java Application. You can load a single tile by sending a completely formatted WMS url which includes the bounds that you want. See the answer from iant for more details.


0

Personnally, I need more input. I maybe misunderstand but it seems to works: I mean I see your geoJSON properties within the data and attributes keys with the values in the debugger complete. I use below code in Firebug at http://dev.openlayers.org/releases/OpenLayers-2.12/examples/draw-feature.html var featuresText = ...


4

If you have to work with a Google base map, OpenLayers 2 will satisfy your needs. As stated in an OpenLayers 3 issue by @ahocevar, There will be no ol.source.GoogleMaps, unless Google change their policy and allow direct access to their map tiles. Your only chance to use Google wiht OpenLayers 3 is to make a base map without any controls with Google ...


2

That is a very hard question to answer. OpenLayers 2 has been very successful and it is easy to find examples for just about everything. OpenLayers 3 is a total rewrite and uses the Google Closure toolkit which provides a number of useful services: code compression, event handling, cross browser support, etc. OpenLayers 3 also uses webGL rendering, when it ...


4

For example: let's say you have a 10 megabyte raster/vector file that covers a large area. If you include the file directly into OpenLayers, it will download the entire file to the browser and render whatever part of it the map needs even if it's a small area. What mapserver will do for you is always deliver to the browser a small image of exactly what ...


1

Your problem may come from using WFS 1.1.0 with a coordinate system that has a northing-easting axis order. You can try these solutions: Use WFS 1.0.0 version. You can test that 1.1.0 sends coordinates as northing-easting ...


0

Based on a suggestion from my friend Danilo Viana, solved the problem by overwriting the OpenLayers.Style.createLiteral behavior like this: OpenLayers.Style.createLiteral = function(value, context, feature, property) { if (typeof value == "string" && value.indexOf("${") != -1) { value = OpenLayers.String.format(value, ...


1

OpenLayers has a GetCentroid function for getting the centre of a polygon if you don't want to bring it in from the database directly: http://dev.openlayers.org/apidocs/files/OpenLayers/Geometry-js.html#OpenLayers.Geometry.getCentroid From there you should just be able to treat the point as a regular point feature. See also this example: ...


3

You need to use WFS-T, the T standing for transactional, which is what's required to be able to write-back. Both Openlayers and GeoServer support this. This question may help on the script side - WFS-T: changes not saved on an OpenLayers map There's also a sample tutorial here: ...


1

If I understand your question, you want to be able to change a property on all or some of the features (on separate layers) on the map. From the ol.map object, you can get the layergroup property. This will give you access to all the layers on the map, you can then just do something like: var layers = map.get('layergroup').getLayersArray(); for (var i in ...


1

You need to get the data from the server in geoJSON format. I can get you an example in PHP if you want, but I think there are plenty examples around. Then in Javascript, you can do something like this: $(document).ready(function(){ setInterval(function() { $.get("datasource.php", function (data) { if ( !data.error ) { ...


-1

try map.events.triggerEvent("click");


0

The basic trick is loop through the features and concatenate result to the innerHTML. var info = document.getElementById('info'); info.innerHTML = ''; // clears out the current content var feature = map.forEachFeatureAtPixel(pixel, function(feature, layer) { info.innerHTML += feature.getId() + ': ' + feature.get('name') + '<br/>'; });


0

Inappropiate place of Openlayers.StyleMap assignment, it should be declared in the layer creation.


0

So I guess the answer to this question is on the manner the other domain is responding to the request. Upon closer inspection of the reply of OSM server (e.g. http://b.tile.openstreetmap.org/6/56/29.png), the header is set to Access-Control-Allow-Origin:* thus there are no cross-origin issue encountered.


2

This example should do what you want: http://openlayers.org/en/master/examples/mouse-position.html It's an OpenLayers Control ( http://dev.openlayers.org/docs/files/OpenLayers/Control/MousePosition-js.html) , but you can get it to point at specific objects on the screen so it gets written there instead. var mousePositionControl = new ...


2

This can simply be done by defining extent in the View object. eg var view = new ol.View({ ... extent: [minx,miny,maxx,maxy] ... }); var map = new ol.Map({ ... view: view, ... });


1

What are looking for is an OpenLayers strategy. You do not use this directly, but one of the subclasses, such as BBOX or Cluster or Fixed. The cluster strategy does as it says and combines point that are close together into clusters, based on a threshold, which will lead to much faster rendering times when you have many points in view. Unfortunately, the ...


2

I think the best approach is to go with Mapserver or Geosever (since you are new, Geoserver will look a lot easier) Once you set a WMS service with geoserver, you can add the resulting WMS to your OpenLayers project. Geoserver automatically returns only the information in the extent of the current view, also you can set the range of visible scales on your ...



Top 50 recent answers are included