1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to add line programatically in open layers 3?

Discussion in 'Geography' started by Vishal, Oct 8, 2018.

  1. Vishal

    Vishal Guest

    I successfully added point like this-

    var iconFeature = new ol.Feature({
    geometry: new ol.geom.Point([8637791.36, 1456487.82]),
    name: 'Police Station',
    population: 4000,
    rainfall: 500
    var vectorSource = new ol.source.Vector({
    features: [iconFeature]

    var vectorLayer = new ol.layer.Vector({
    source: vectorSource,
    title: 'point_layer'

    But failing to add line feature like this and assigning various properties like that I assigned to point feature,Polygon feature was added by below code-

    var ring = [[77.4700927734375, 12.906190219892437],[77.4707794189453, 12.987162237749473],
    [77.5188446044922, 12.989838549012532],[77.51060485839844, 12.961066692801282],
    [77.51747131347656, 12.953705916047227],[77.52708435058594, 12.94500653581774],
    [77.51815795898438, 12.936306851970144],[77.50030517578125, 12.92426063498786],
    [77.486572265625, 12.912883118595701],[77.4700927734375, 12.906190219892437]];
    var polygon = new ol.geom.Polygon([ring]);
    polygon.transform('EPSG:4326', 'EPSG:3857');
    var polygonfeature = new ol.Feature(polygon);
    var property = { "name": "Boundary"};
    var vectorSource1 = new ol.source.Vector();
    var vectorLayer1 = new ol.layer.Vector({
    source: vectorSource1,
    title: 'polygon_layer'
    Please suggest to add line feature with some properties so that those can be displayed on mouse click.

    Login To add answer/comment

Share This Page