How to create circular polygon in openlayers 3?

المشرف العام

Administrator
طاقم الإدارة
So i would really like to modify this example:http://openlayers.org/en/v3.0.0/examples/tissot.html?q=circle

Problem there is that wheter i try to apply it to my map it doesen`t work, probably because i use OSM tyle which is not spherical:

var map = new ol.Map({ layers: [ new ol.layer.Tile({ source: new ol.source.OSM() }), new ol.layer.Vector({ source: vectorSource }) ], renderer: 'canvas', target: 'map', view: new ol.View({ center: ol.proj.transform([2.1833, 41.3833], 'EPSG:4326', 'EPSG:3857'), zoom: 2 })});And for the question: how to create circular polygon?As i can see, there's two choices:1. somehow convert geom.Circle in geom.Polygon, which i cant do, based on my noob level2. create my own function to do that, something like openlayers 2:

OpenLayers.Geometry.Polygon.createRegularPolygon = function(origin, radius, sides, rotation) { var angle = Math.PI * ((1/sides) - (1/2)); if(rotation) { angle += (rotation / 180) * Math.PI; } var rotatedAngle, x, y; var points = []; for(var i=0; i
 
أعلى