openlayers-3

OpenLayers - add click event on ol.Overlay

北慕城南 提交于 2019-12-08 11:43:02
问题 I want to add click event to ol.Overlay in OpenLayers. What would be the best way to do this? Reason for using ol.Overlay: I want to add a custom marker with image and text that could be changed dynamically. For this, I am using ol.Overlay to add HTML in element as follows: // Add markers var marker = new ol.Overlay({ position: ol.proj.fromLonLat(lng1, lat1), positioning: 'center-center', element: $(getMarkerContent()) }); map.addOverlay(marker); function getMarkerContent() { var content = "

OpenLayers 4 - fit to extent of selected features

允我心安 提交于 2019-12-08 11:21:29
问题 Me again. So, yesterday I faced a bit of a problem with zooming to selected features and I'm hoping that some of you can push me in right direction.Here it goes... I'm trying to implement autocomplete/search bar using Materialize Materialize Framework. (Here is fiddle example of simple searchbar) $(document).ready(function(){ $('input.autocomplete').autocomplete({ data: { "Apple": null, "Microsoft": null, "Google": 'https://placehold.it/250x250' }, }); }); Now, what I'm trying to do is to

ol.interaction.Select gives an error on ol.source.VectorTile

☆樱花仙子☆ 提交于 2019-12-08 07:21:01
问题 I'm trying to change the style of a feature in a VectorTile layer once it is selected. However the first time the select interaction is triggered the console reports an error: Uncaught TypeError: feature.getId is not a function at ol.source.Vector.addToIndex_ (ol-debug.js:66819) at ol.source.Vector.addFeatureInternal (ol-debug.js:66772) at ol.source.Vector.addFeature (ol-debug.js:66759) at ol.source.Vector.<anonymous> (ol-debug.js:66919) at ol.Collection.boundListener (ol-debug.js:3441) at ol

Is there a 'getZoomForResolution' in OpenLayers 3?

六月ゝ 毕业季﹏ 提交于 2019-12-08 05:06:17
问题 OpenLayers 2 used to have a getZoomForResolution method that would give you the zoom level (or closest zoom level) of a given resolution. I don't see any such method in ol3, for the ol.View object that is. Is there a way to achieve this with what ol.view currently have ? 回答1: This will give the next closest integer zoom for a give resolution: function zoomForResolution(resolution) { var zoom = 0; var r = 156543.03390625; // resolution for zoom 0 while (resolution < r) { r /= 2; zoom++; if

Displaying features based on zoom level

╄→гoц情女王★ 提交于 2019-12-08 04:43:04
问题 I'm new to openlayers library and I got a question. I render a lot of features and when the map is zoomed out the features overlay each other, which looks pretty ugly, as you can see on the first screenshot. I'd like the zoomed-out map(first screen) to look like zoomed-in map(second screen) at all zoom levels. What would be the most common way of implementing it? 回答1: Here is an example of a style function that detects group features from a cluster map layer and draws a square for individual

How to rotate text with view using OpenLayers 3

旧街凉风 提交于 2019-12-08 02:56:02
问题 I am developing a navigation application, which draws planned route on a map. Planned route consists of points connected with a line. Each point is labelled with distance and direction. When I initially draw the route on the map, I calculate text position in a way, where it doesn't interfere with the line - I use offsetX, offsetY and rotation style attributes. Unfortunately, when the map view is rotated, not of the mentioned attributes is changed - text is not rotated. Is there a way, how to

Fixed icon size in OpenLayers 3

懵懂的女人 提交于 2019-12-08 02:16:59
问题 I searched for 2 hours now, but it's still not clear if it's possible or not in OL3. I would like my icons to be fixed size (not to the screen, but to the image map I'm using). I mean, it should cover the same area even if I'm zoomed out, and not covering the half of the map (like I was using a circle polygon, but I have complex Icons so I have to use it as point features). Is there any solution to it? Like in QGIS: MAP UNITS. I already have these: var jelekStyle = function(feature,

Set style zoom level openlayers 3

北战南征 提交于 2019-12-08 02:01:13
问题 In Openlayers it was possible to turn certain features on or off depending on the zoom level. I have not found the same functionality in OpenLayers 3 despite looking through the documentation. Does anyone know how to do this? This is the feature I'm placing on the map and ol.style.Text is what I would like to display only after the user is zoomed in to a particular zoom level. var geoJsonObj = { 'type': 'Feature', 'geometry': JSON.parse(response.FieldList[key].Shape) } var vectorSource = new

How can we render an OpenLayers 3 feature to a canvas using a style but not using a map?

[亡魂溺海] 提交于 2019-12-08 01:54:17
问题 QUESTION : How can we render a feature to a canvas using a style but not using a map? BACKGROUND : I have a sample which renders a geometry to a canvas honoring the ol3 style but it only runs with the unbuilt version of openlayers (ol-debug.js) and because it makes use of private functions (ol.vec.Mat4). works when using ol-debug.js fails when using ol.js One alternative is to create a map, add a vector layer, set the style on the feature, add the feature to the layer and remove all the

Draw a circle with defined diameter in OpenLayers

寵の児 提交于 2019-12-08 01:14:25
问题 I'm trying to write a code which let my users define some points on the map and once they created a point, the program should draw a circle with defined diameter(in kilometers or ... ) around the point. I can draw a point but I don't know how I could handle what I said. Here is an example about what I want: 回答1: Use the following function to create circular points around a point. //pass the //@pointX, //@pointY, //@radius of circle (in your case diameter/2) //@pointsToFind this is how detail