window.Map = { map: undefined, ipath : 'img/marker.png', init : function() { this.map = new OpenLayers.Map({div:"osmap", zoom:12}); this.map.addLayer(new OpenLayers.Layer.OSM()); this.marker = new OpenLayers.Layer.Markers(); this.map.addLayer(this.marker); var size = new OpenLayers.Size(21,25); var offset = new OpenLayers.Pixel(-(size.w/2), -size.h); this.icon = new OpenLayers.Icon(this.ipath, size, offset); }, addMarker : function(lon, lat) { this.marker.addMarker(new OpenLayers.Marker(this.coords(lon, lat), this.icon.clone())); this.map.setCenter(this.coords(lon, lat)); }, coords : function (lon, lat) { return new OpenLayers.LonLat(lon, lat).transform( new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913") ); } };