[OpenLayers-Dev] make a point on a map

steve1000 ligerstephane at free.fr
Tue Feb 19 18:13:14 EST 2008


Hi Martijn,
I found it, it's good. Thank you really for your reponse.
The next time, I will explain a few more. 
My code to put into the function init(){ }of your page html  
map.events.register("click", map, function(e) {    
		var lonlat = map.getLonLatFromViewPortPx(e.xy);    
		document.getElementById('Nord').value = lonlat.lat; 
		document.getElementById('Est').value = lonlat.lon; 
		var markers = new OpenLayers.Layer.Markers( "Markers" );
		map.addLayer(markers);
		var size = new OpenLayers.Size(10,17);
		var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
		var icon = new OpenLayers.Icon('../img/marker.png',size,offset);
		markers.addMarker(new OpenLayers.Marker(new
OpenLayers.LonLat(lonlat.lon,lonlat.lat),icon));
		markers.addMarker(new OpenLayers.Marker(new
OpenLayers.LonLat,icon.clone(lonlat.lon,lonlat.lat)));
		});

A+, Have a nice day,

Stéphane
-- 
View this message in context: http://www.nabble.com/make-a-point-on-a-map-tp15478972p15578457.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.




More information about the Dev mailing list