[OpenLayers-Users] How to add a an overlay on top of a map?

Jatin Ambasana jatin.a at iworktech.com
Tue Jan 27 03:28:22 EST 2009


hey newbie...

For drawing vector features.....
you can refer to
http://openlayers.org/dev/examples/draw-feature.html
http://openlayers.org/dev/examples/drag-feature.html

To achieve the functionality you need you can follow any of 2 methods
mentioned below:

1)Change the following code in draw-feature.html:

// This lets you call a function when a feature is inserted on vector layer
var lineLayer = new OpenLayers.Layer.Vector("Line Layer",{onFeatureInsert:
featureIsAdded});

//Add this funtion in your code
function featureIsAdded(feature){
	alert("Feature with id: "+feature.id+", has following Geometry:
"+feature.geometry);
}

I feel that would be sufficient for you......

2)There is also another nice example but some what different that you can
see from:
http://openlayers.org/pipermail/users/2007-June/001998.html
http://openlayers.org/pipermail/users/2007-June/001998.html 

I have modified that code and I am attaching that with this post.... But it
has few problems.... It does show you the co-oridnates of all points of the
line drawn but it does not add the line to the Line Layer...

I don't understand why it works in the previous standard OpenLayers example
and not in the second example that I downloaded from above link......

If someone has solution for that then that would nice of him/her.....


newbie wrote:
> 
> Dear All,
>            I am using geoserver and managed to put a sample shapefile and
> able to view my simple map well. The problem now is that on top that map I
> want to add a layer where I can like draw polygon and capture the
> coordinates accordingly. How can I do this ? Thanks.
> 

-- 
View this message in context: http://n2.nabble.com/How-to-add-a-an-overlay-on-top-of-a-map--tp2196295p2222981.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list