user512663
user512663

Reputation: 173

How to set a new position/radio for a circle with openlayers?

In this example or in this, how can I move the circle to a new position and change the radio on fly?

I tried, but it is not working:

circle.setPosition(ol.proj.transform([GPS_lon, GPS_lat], 'EPSG:4326', 'EPSG:3857'));

PS: I'm not even sure if I can create a circle in an easiest way :$

Thanks in advance!

Upvotes: 0

Views: 341

Answers (1)

tsauerwein
tsauerwein

Reputation: 6011

ol.geom.Circle has two methods that you can use for this: setCenter(center) and setCenterAndRadius(center, radius, opt_layout).

circle.setCenterAndRadius(
    ol.proj.transform([4.1833, 46.3833], 'EPSG:4326', 'EPSG:3857'),
    500000
);

http://jsfiddle.net/ob7ggtx6/72/

Upvotes: 1

Related Questions