Probably one of the first things you would want to do with an openlayers map is adding some interaction.
Amazingly it is difficult to find an easy and quick example on how to do it.
Here is an example on how to move an Openlayer.Marker to the point where a user clicked on the map.
var markers = new OpenLayers.Layer.Markers( "Markers" );
marker = new OpenLayers.Marker(lonLat) ;
markers.addMarker(marker);
map.addLayer(markers);
map.events.register("click", map , function(e){
var opx = map.getLayerPxFromViewPortPx(e.xy) ;
marker.map = map ;
marker.moveTo(opx) ;
});
Another example can be found on the openlayers examples page.
I found it a bit overkill though and more difficult to use.
Comments
Leave a comment Trackback