[OpenLayers-Users] Popups for waypoints?

Jan Martin janmartin3 at googlemail.com
Sun Aug 2 14:37:05 EDT 2009


Hello,

the file in this mail displays waypoints from a gpx file.
*
*Special features:
- auto-zoom
- auto-center

What do I need to change to get a popup when clicking a waypoint?
*
*The popup should show "name" and "desc".

Thanks,
Jan

Waypoints look like this:

<wpt lat="49.123456789" lon="8.123456789">
  <ele>170.555686</ele>
  <time>2009-08-01T17:29:29Z</time>
  <name>00000001</name>
  <cmt>00000001</cmt>
  <desc>00000001</desc>
</wpt>


Page:

<html>
    <head>

    <title>I want popups!</title>

    <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
    <script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script>

        <script type="text/javascript">
            var map;
            function init() {
                map = new OpenLayers.Map ("map", {
                    controls:[
                        new OpenLayers.Control.Navigation(),

                        new OpenLayers.Control.PanZoomBar(),
                        new OpenLayers.Control.LayerSwitcher(),
                        new OpenLayers.Control.Attribution()],
                    maxExtent: new
OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),

                    maxResolution: 156543.0399,
                    numZoomLevels: 19,
                    units: 'm',
                    projection: new OpenLayers.Projection("EPSG:900913"),

                    displayProjection: new OpenLayers.Projection("EPSG:4326")
                } );

                layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
                map.addLayer(layerMapnik);

                layerTilesAtHome = new
OpenLayers.Layer.OSM.Osmarender("Osmarender");
                map.addLayer(layerTilesAtHome);
                layerCycleMap = new OpenLayers.Layer.OSM.CycleMap("CycleMap");

                map.addLayer(layerCycleMap);

    var dataExtent;
    var setExtent = function() {
       if(dataExtent) {
           dataExtent.extend(this.getDataExtent());
       } else {
           dataExtent = this.getDataExtent();

       }
       map.zoomToExtent(dataExtent);
    };
                    lgpx = new OpenLayers.Layer.GML (
                               "wpt.gpx (red)",
                               "wpt.gpx",

                               {
                        projection: new  OpenLayers.Projection("EPSG:4326"),
    //                    style: {strokeColor: "red", strokeWidth: 5,
strokeOpacity: 0.8},

                        format: OpenLayers.Format.GPX,
                               }
                        );
                    lgpx.events.register("loadend", lgpx, setExtent);
                    map.addLayer(lgpx);


            map.setCenter(null, null);
            };
    </script>
    </head>

    <body onload="init();">
    <div style="width:90%; height:90%" id="map"></div>

    </body>
    </html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090802/533f0f54/attachment.html


More information about the Users mailing list