NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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's gravatar image

dada3781
11112
accept rate: 0%

closed 11 Jan '12, 08:45

Andy%20Allan's gravatar image

Andy Allan
12.5k23128153

The question has been closed for the following reason "This is a support system for OpenStreetMap contributors, not OpenLayers. See http://openlayers.org for more information on OpenLayers." by Andy Allan 11 Jan '12, 08:45

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×39
×12
×9

question asked: 10 Jan '12, 18:49

question was seen: 6,106 times

last updated: 11 Jan '12, 08:45

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum