[OpenLayers-Users] Text in Markers

David Lozzi dlozzi at delphi-ts.com
Tue Oct 13 18:25:54 EDT 2009


Thanks Chris, but I can't figure it out. 

 

I added the code (see below) as noted but nothing happens when I click a
marker. When it finishes loading there is no error. One question I have
is that the functions are accessing attribute values that I haven't set.
I'm thinking that's causing the issue? How do I go about setting my
attributes to show?

 

        var lon = 50;

        var lat = 0;

        var zoom = 0;

        var map, layer;

        var markers;

        var icon;

        

        function init(){

            OpenLayers.DOTS_PER_INCH = 72;

 

            map = new OpenLayers.Map( 'map',{numZoomLevels: 20,controls:
[

                    new OpenLayers.Control.Navigation(),

                    new OpenLayers.Control.PanZoomBar(),

                    new OpenLayers.Control.LayerSwitcher()

                ]});// , options);

            

            format = 'image/png';

            

            // setup tiled layer

            tiled = new OpenLayers.Layer.WMS(

                "Roads and Boundaries",
"http://giswebservices.massgis.state.ma.us:80/geoserver/wms",

                {

                    layers:
'massgis:GISDATA.NAVTEQRDS_ARC,massgis:GISDATA.NAVTEQRDS_ARC_STATE'

                }

            );

 

            markers = new OpenLayers.Layer.Markers( "Markers" );

 

            var size = new OpenLayers.Size(10,17);

            var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);

            icon = new
OpenLayers.Icon('/_layouts/DHQMap/img/marker.png',size,offset);

            map.addLayers([tiled, markers]);

                                                markers.addMarker(new
OpenLayers.Marker(new
OpenLayers.LonLat(-71.1450838964564,42.6050076297885),icon.clone()));

                                                markers.addMarker(new
OpenLayers.Marker(new
OpenLayers.LonLat(-71.1622603445945,42.5458662248818),icon.clone()));

                                                markers.addMarker(new
OpenLayers.Marker(new
OpenLayers.LonLat(-71.1491479425792,42.5394078098106),icon.clone()));

                                                markers.addMarker(new
OpenLayers.Marker(new
OpenLayers.LonLat(-71.1460689446781,42.6019899993857),icon.clone()));

            markers.events.on({'featureselected':
onFeatureSelect,'featureunselected': onFeatureUnselect});

 

                                                map.setCenter(new
OpenLayers.LonLat(-71.1491479425792,42.5394078098106), 15);

        }

                                

function onPopupClose(evt) {

    // 'this' is the popup.

    selectControl.unselect(this.feature);

}

function onFeatureSelect(evt) {

    feature = evt.feature;

    popup = new OpenLayers.Popup.FramedCloud("featurePopup",

 
feature.geometry.getBounds().getCenterLonLat(),

                             new OpenLayers.Size(100,100),

                             "<h2>"+feature.attributes.title + "</h2>" +

                             feature.attributes.description,

                             null, true, onPopupClose);

    feature.popup = popup;

    popup.feature = feature;

    map.addPopup(popup);

}

function onFeatureUnselect(evt) {

    feature = evt.feature;

    if (feature.popup) {

        popup.feature = null;

        map.removePopup(feature.popup);

        feature.popup.destroy();

        feature.popup = null;

    }

}

 

Thanks,

 

David Lozzi

Product Development Manager

Delphi Technology Solutions, Inc.

(978) 988-8007 x204 - www.delphi-ts.com <http://www.delphi-ts.com/> 

 

Blog <http://www.delphi-ts.com/blogs/lozzi>   -  LinkedIn
<http://www.linkedin.com/in/davidlozzi>   - Twitter
<http://www.twitter.com/davidlozzi>   

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20091013/6fab50e5/attachment.html


More information about the Users mailing list