[OpenLayers-Users] adding points by inserting coordinates

toni hernández tonidelacalle at gmail.com
Fri Apr 3 02:51:39 EDT 2009


Hi,
I'am not an expert but you could do something like this.

//in your init function
//define the style of your layer
var myStyles = new OpenLayers.StyleMap({
    "default": new OpenLayers.Style({
    fillColor: "#ffcc66",
    strokeColor: "#ff9933",
    strokeWidth: 2
    })
});

//Create a layer to pur your points in
var points = new OpenLayers.Layer.Vector(
    'Points', {styleMap: myStyles}
);
.........

Create a new function..
Assuming the input elements are called lon and lat
function createPoint()
{
    //create your point with your values
    newpoint = new OpenLayers.Feature.Vector(
        new OpenLayers.Geometry.Point(
            (document.forms.yourform.lon.value,
document.forms.yourform.lat.value)
        )
    );
    //add point to layer
    points.addFeatures(features);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090403/5b807b37/attachment.html


More information about the Users mailing list