Tag Info

New answers tagged

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)


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


0

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 ...


1

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 ...


0

Same issue for me. Reverting to 2.11 has corrected.


1

You can set the base layer by doing: var layers = this.map.getLayers(); layers.insertAt(0, base_layer);


0

I think you may need to add custom controls to default ones instead of extending it. Can you try like this ? .. controls: ol.control.defaults({}, [ new ol.control.FullScreen(), ..others if you want to.. }) ..


2

Lets assume you want to save a feature from a OpenLayers Vector Layer into PostGis and that you want to achieve this using GeoServer. The general steps would be as follows: You need to configure a WFS in geoserver using PostGis as a data store (GeoServer publish posgis table) You need to configure your vectyor layer to point to the wfs you just created ...


2

http://jsfiddle.net/a6pp9vwz/9/ working for me. Console log said "$ not defined". $ is a jQuery class, so you need a jQuery environment to enable AJAX requests. You can enable jQuery in JSFiddle in the "Frameworks & Extensions" tab.


1

thanks my friend Chris, he's truly help me resolved the problem... and the anser will be like this.. http://jsfiddle.net/v18kuxgf/ polygonLayer.events.register('featureadded', null, function(event) { var feature = event.feature, geometry = feature.geometry; if (geometry.getArea() ...


2

You can use the write function of the OpenLayers.Format.GeoJSON to generate (Geo)JSON directly. The input is either an OpenLayers geometry, feature or feature vector, so the returned JSON, will either contain one or many features depending on the input. Note if your OpenLayers Features have attributes, these get turned into JSON too, so you can use this to ...


7

Why use a database? Because it's not necessarily the case, especially with larger datasets, that you can expect to be able to push the entire thing to the client. If you're talking thousands of points, then sure, but for millions of points you probably don't want each and every one represented in RAM on your end users' client. Not everyone has a super fast ...


1

I got it : I just deleted onPopupClose from popup definition in function monpopup(event). Now white cross does its job


0

The previous answer has an invalid xmlns. I think the correct one will be: <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <Document> <Style id="0"> </Style> <Placemark> <Polygon> <outerBoundaryIs> <LinearRing> <coordinates> ...


0

I figured out that the solution could come from a software called QGIS. I used a plugin called 'Afine Transformation' and moved my whole layer to the left or right and then reloaded all of my data on the database and the geoserver.


3

Google maps is not a WMS service, and the terms of use of Google Maps itself prevent legal usage of it in a server side application, unless of course you have some sort of commercial contract with Google that entitles you to use their tiles outside of a browser.


0

OK, so I figured out what is wrong! I needed to change the position of the transparent statement like this: Notice that transparent statement has gone in the above bracket. Thanks everybody for participating!


1

Check your Geoserver Layer Setup. Open the WMS layer and go to the Publishing Tab .. There is a check box under WMS Settings labeled Opaque, make sure that this is unchecked.


1

I don't even think being able to extract the T and V, if possible, is gonna be reliable cross-browsers. Might just be a browser interpretation thing. In any case, if you have access to it, I would just add your own attribute when you're creating the layer: var foo_layer = new ol.layer.Vector(...); foo_layer.layer_type = 'vector'; Then you can use it later ...


1

Check your coordinates in these layers. Maybe they don't match on each other and you are switching from one system to another with layer switching... I am not sure what are your WMS made of. Is that blue line a vector? If it is raster it can cover all other layers (it has no transparency) with white border we see around line (maybe it has defined boundaries ...


3

I use Leaflet with SVGs as the maps. I do this because I want the map functionality on top of a floor plan. In my experience, it works much better than Raphael.js (maybe just because it's newer?), which my company used for the same purpose on a previous project. I have also made map tiles out of floor plans, but the SVGs are faster and smoother when zooming ...


1

Finally I found the trick. When an attribution control is created, OL actually creates a DOM element with class name .olControlAttribution. So with simple jquery, we can update the content with: $(".olControlAttribution").html("some_updated_text"); Nice thing is, since it's DOM element, we can put any html tag inside it; including <img> which is ...



Top 50 recent answers are included