Example of using the WKT parser.
Create features from geometries in WKT (Well Known Text) format.
<!DOCTYPE html> <html> <head> <title>WKT example</title> <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <link rel="stylesheet" href="http://openlayers.org/en/3.8.1/css/ol.css" type="text/css"> <script src="http://openlayers.org/en/3.8.1/build/ol.js"></script> </head> <body> <div class="container-fluid"> <div class="row-fluid"> <div class="span12"> <div id="map" class="map"></div> </div> </div> </div> <script> var raster = new ol.layer.Tile({ source: new ol.source.OSM() }); var format = new ol.format.WKT(); var feature = format.readFeature( 'POLYGON((10.689697265625 -25.0927734375, 34.595947265625 ' + '-20.1708984375, 38.814697265625 -35.6396484375, 13.502197265625 ' + '-39.1552734375, 10.689697265625 -25.0927734375))'); feature.getGeometry().transform('EPSG:4326', 'EPSG:3857'); var vector = new ol.layer.Vector({ source: new ol.source.Vector({ features: [feature] }) }); var map = new ol.Map({ layers: [raster, vector], target: 'map', view: new ol.View({ center: [2952104.019976033, -3277504.823700756], zoom: 4 }) }); </script> </body> </html>