openlayers-3

Openlayers 3 center map

∥☆過路亽.° 提交于 2019-12-04 23:03:32
I'm sing OpenLayers 3 to display a map. I want to center the map using latLon coordinates. I'm using the quickstart code to begin with. Using this code, I cannot change the center of the map. I think this has something to do with Spherical Mercator projection . Only thing is, I only have lat lon coordinates. Does anyone know how to center a map from openlayers v3? Ole Borgersen You need to transform the lon/lat coordinates to the correct projection (or coordinate system) using var olCoordinates = ol.proj.transform([lon, lat],"WGS84", "EPSG:900913") Now you can set center with olCorrdinates.

Is Displaying 1000+ Feature Footprint Vectors on OpenLayers Map with Good Performance Possible? [closed]

我与影子孤独终老i 提交于 2019-12-04 22:10:44
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . When loading many feature footprint vectors onto the map, the openlayers map and web application becomes unresponsive. Is there any way to improve the performance of the openlayers map with many vectors? We would like to be able to support at least 1000 vectors on the map at once. We are using openlayers 4. As I can tell, OpenLayers 3+ uses HTML5 canvas to render images and vectors. I've seen the canvas being used

getFeatures() is empty

◇◆丶佛笑我妖孽 提交于 2019-12-04 21:10:39
I have a similar question like POI in OpenLayer 3 but not the same. I'm drawing a map with an KML File: var layerVector = new ol.layer.Vector({ source : new ol.source.KML({ projection : projection, url : _url }), }); It works fine and I can see the points from the KML file in the map. (Using <Style> and <styleUrl> Tags in the KML file.) But if I try to see the features i get an empty Array. console.log( layerVector.getSource().getFeatures() ); ==> Array [ ] any idea? thx mx See the answer in our upcoming FAQ: https://github.com/openlayers/ol3/blob/master/doc/faq.md from the above link: Why

Openlayers 3: add text label to feature

淺唱寂寞╮ 提交于 2019-12-04 19:55:42
问题 I have the current set up here: fully functional fiddle example and whilst I have managed to zoom to each polygon feature I would also like to display a centralised text label on each... the field_title variable found within the get_fields method. I have no idea how to do this and all my googling has come up with this article: http://openlayers.org/en/v3.3.0/examples/vector-labels.html which I find totally confusing as I'm a little new to OL! 回答1: To add a text to ol.Feature you will store

How to get a layer from a feature in Openlayers 3?

老子叫甜甜 提交于 2019-12-04 18:32:06
问题 I can't find a way to go from a feature in a selection event to a layer that it may be a part of without traversing all the features of all my map layers, or storing an artificial layer ID within every feature at creation. Is this just not possible yet? ol.js 3.7.0 ol.interaction.Selection -> click -> callback( event ){ event.selected[0] } In another part of my app, I would like to go from the feature to the layer to determine the style being used on the feature, specifically whether or not

Is there anyway to specify z-order of feature on single layer?

此生再无相见时 提交于 2019-12-04 14:39:34
I am using single layer with three feature and would like to specify z-order but not working anyway. As per my understanding feature is drawing in same order in which I am adding so I tried by adding in reverse order but it not worked for me. Code to add feature var features=[]; jQuery.each(data.route, function (key, val) { var localfeature = new ol.Feature({ geometry: objGeoJSON.readGeometry(JSON.parse(val.simpleRoute)).transform('EPSG:4326', 'EPSG:3857') }); localfeature.set("rtype", "R" + (key + 1)); features.push(localfeature); }); currentRoute.routingSource.addFeatures(features); Style

OpenLayers 3 and XYZ Layer

ぃ、小莉子 提交于 2019-12-04 12:02:44
I have a map, which I want to display. It consists of a standard map (OSM, Google or Bing) and a layer, provided by Openseamap.org. This layers produces seamarks as images for a map. This should look like this (more or less, without the pink screen): I am trying to transfer this to OpenLayers3. The JavascriptCode I used is: var map = new ol.Map({ target: 'map', layers: [ new ol.layer.Tile({ source: new ol.source.OSM() }), new ol.layer.Tile({ source: new ol.source.XYZ({ url: 'http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png', crossOrigin: 'null' }) })], view: new ol.View2D({ center: ol.proj

Openlayers 3: Select a feature programmatically

▼魔方 西西 提交于 2019-12-04 10:29:50
问题 I am trying to upgrade my system from Openlayers 2 to Openlayers 3 and I have having one particular issue that I cannot seem to figure out. My application has a grid and a map and when a user clicks on the grid I want to select the relevant point on the map. In Openlayers 2 I used the following: self.selectControl.select(feature[0]); I cannot find or understand how to do the same in Openlayers 3. So to be clear, I have a feature which I have found programmatically and I want to select that

OpenLayers and TypeScript?

╄→гoц情女王★ 提交于 2019-12-04 07:51:15
I was wondering if anybody knows if there are any existing TypeScript definition files for OpenLayers (or if they are already in the making). I tried parsing the OpenLayers source files myself and use the documentation comments to build a TypeScript definition file but to really make this work I would need a complete JavaScript parser that also understand the documentation syntax in OpenLayers (it uses NaturalDocs, http://naturaldocs.org ) and I'm beginning to think that translating the info by hand is easier than writing such a parser :(. So does anybody now of a similar project or has an

Openlayers-3 Force a map refresh

醉酒当歌 提交于 2019-12-04 06:35:10
I have a custom styling that shows/hides features on the map, but when it is applied it doesn't activate until the map refreshes due to a feature update, but I need it to trigger immediately. I tried map.render and renderSync() but they did nothing. mapResize() doesn't appear to do anything either, but if I wait for a feature to be updated or move the map it works. Any ideas? How can I FORCE the map to redraw on demand, regardless of a feature update? I believe you need to force your layer's source to update, you can do so by calling the changed function on it: yourLayer.getSource().changed();