Hi all, I have been fiddling with this way too long already, so I ask: After changing the Click Event Example a bit I am getting coordinates like this:
5383153.349692758 1323087.0961396247 Click Event Example: http://www.openlayers.org/dev/examples/click.html However I need them like this: 43.468243 11.880172 Btw. same format as the coordinates in the "data.txt". I think "All I DID" is changing from WMS to OSM Layers? How to automatically convert? Thanks. Please find my code: <html> <head> <title>map3</title> <style type="text/css"> #map { width: 90%; height: 90%; border: 1px solid black;} </style> <script src="OpenLayers.js"></script> <script src="OpenStreetMap.js"></script> <script type="text/javascript"> OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { defaultHandlerOptions: { 'single': true, 'double': false, 'pixelTolerance': 0, 'stopSingle': false, 'stopDouble': false }, initialize: function(options) { this.handlerOptions = OpenLayers.Util.extend( {}, this.defaultHandlerOptions ); OpenLayers.Control.prototype.initialize.apply( this, arguments ); this.handler = new OpenLayers.Handler.Click( this, { 'click': this.trigger }, this.handlerOptions ); }, trigger: function(e) { var lonlat = map.getLonLatFromViewPortPx(e.xy); alert("You clicked: " + lonlat.lat + " " + lonlat.lon); } }); var map; function init() { map = new OpenLayers.Map ("map", { controls:[ new OpenLayers.Control.Navigation(), new OpenLayers.Control.PanZoomBar(), new OpenLayers.Control.LayerSwitcher(), ], } ); layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik"); map.addLayer(layerMapnik,{layers: 'basic'}); layerTilesAtHome = new OpenLayers.Layer.OSM.Osmarender("Osmarender"); map.addLayer(layerTilesAtHome); layerCycleMap = new OpenLayers.Layer.OSM.CycleMap("CycleMap"); map.addLayer(layerCycleMap); var click = new OpenLayers.Control.Click(); map.addControl(click); click.activate(); var dataExtent; var setExtent = function() { if(dataExtent) {dataExtent.extend(this.getDataExtent());} else {dataExtent = this.getDataExtent();} map.zoomToExtent(dataExtent); }; var newl = new OpenLayers.Layer.Text( "text", { location: "data.txt", } ); newl.events.register("loadend", newl, setExtent); map.addLayer(newl); map.setCenter(null, null); }; </script> </head> <body onload="init();"> <div id="map"></div> </body> </html>
_______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
