Ignore:
Timestamp:
Dec 15, 2007, 12:52:34 PM (12 years ago)
Author:
Nick Burch
Message:

Tweak a few bits

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/openspace.npemap.org.uk/index.html

    r612 r614  
    3131   
    3232        function drawExisting() {
     33                // Clear all our makers
     34                markers.clearMarkers();
     35
     36                // Only display at zoom levels 8+
     37                if(osMap.zoom < 8) {
     38                        return;
     39                }
     40
    3341                var bounds = osMap.calculateBounds();
    3442                var params = "mineasting=" + bounds.left + "&maxeasting="  + bounds.right + "&minnorthing=" + bounds.bottom + "&maxnorthing=" + bounds.top + "&grid=" + grid;
     
    4250                });
    4351        }
     52
     53        function addNew(e) {
     54                var en = 
     55                        osMap.getLonLatFromViewPortPx( osMap.events.getMousePosition(e) );
     56                var easting = en.lon;
     57                var northing = en.lat;
     58                alert("e=" + easting + " n=" + northing);
     59        }
    4460   
    4561    function init()
     
    5066                markers = new OpenLayers.Layer.Markers("Markers");
    5167        osMap.addLayer(markers);
     68
     69                osMap.events.register("moveend", osMap, drawExisting);
     70                osMap.events.register("zoomend", osMap, drawExisting);
     71                osMap.events.register("click", osMap, addNew);
    5272       
    5373                drawExisting();
     
    7595<h1>Displaying a marker on a map</h1>
    7696
    77 <div id="map" style="width: 500px; height: 300px; border: 1px solid black;"></div>
     97<div id="map" style="width: 800px; height: 500px; border: 1px solid black;"></div>
    7898
    7999<div id="spinner" />
Note: See TracChangeset for help on using the changeset viewer.