Hi, I try to mark points on a OSM map temporarily and store the coordinates to them locally at the same time. The site is just running locally (using Aptana). My issue is that as soon as I activate the draw.feature layer for points the local store routine stops working... The JS code below for reference. Any idea how to do this? Currently I store to local storage, but I am open to other options for this (i.e. export to file or something like this)
var lon = 13.33; var lat = 52.51; var zoom = 10;
var map, vectors, controls;
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 = new OpenLayers.LonLat(1, 1);
lonlat = map.getLonLatFromViewPortPx(e.xy);
var projout = new OpenLayers.Projection("EPSG:4326");
lonlat.transform(map.getProjectionObject(), projout);
reclat = lonlat.lat;
reclon = lonlat.lon;
var blockrec= prompt(reclat + " lat, " +
+ reclon + " lon","");
if (blockrec!=null && blockrec!="")
{
var latulon = ", " + reclat + ", " + reclon;
alert(blockrec + latulon);
localStorage.setItem(blockrec, latulon );
}
}
});
function init(){
map = new OpenLayers.Map('map');
var osm = new OpenLayers.Layer.OSM("OSM");
var newl = new OpenLayers.Layer.Text( "text", {location: "textfile.txt"} );
var pointLayer = new OpenLayers.Layer.Vector("Point Layer");
map.addLayers([osm, newl, pointLayer]);
var click = new OpenLayers.Control.Click();
map.addControl(click);
click.activate();
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
var reg = new OpenLayers.Control.DrawFeature(pointLayer,OpenLayers.Handler.Point);
map.addControl(reg);
reg.activate();
map.setCenter(
new OpenLayers.LonLat(lon, lat).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
), zoom
);
}
Thanx!
asked 10 Jan '12, 18:49

dada3781
11●1●1●2
accept rate: 0%
closed 11 Jan '12, 08:45

Andy Allan
12.5k●23●128●153