Changeset 253


Ignore:
Timestamp:
Apr 20, 2010, 9:07:14 AM (14 years ago)
Author:
Andrej Dundović
Message:

dodan X na popup, ticket #58

File:
1 edited

Legend:

Unmodified
Added
Removed
  • linux-za-sve/karta/frontend/js/LinuxMap.js

    r222 r253  
    66    var map, layer, drawControls, selectControl, selectedFeature;; //complex object of type OpenLayers.Map
    77 
    8         function onPopupClose( feature ) {
    9             selectControl.unselect(selectedFeature);
     8        function onPopupClose(evt) {
     9            drawControls['select'].unselectAll();
    1010        }
    11         function onFeatureSelect( feature ) {
    12             selectedFeature = feature;
     11        function onFeatureSelect(event) {
     12            var feature = event.feature;
    1313            OpenLayers.Popup.FramedCloud.prototype.autoSize = false;
     14            var content = "<h2>"+feature.attributes.title + "</h2>" + feature.attributes.description;
    1415
    1516            popup = new OpenLayers.Popup.FramedCloud("marker",
    1617                                     feature.geometry.getBounds().getCenterLonLat(),
    17                                      new OpenLayers.Size(215, 210),
    18                                      "<h2>"+feature.attributes.title + "</h2>" +
    19                                           feature.attributes.description,
    20                                      null, false, onPopupClose);
     18                                     new OpenLayers.Size(245, 225),
     19                                     content,
     20                                     null, true, onPopupClose);
    2121            feature.popup = popup;
    22             popup.feature = feature;
    23             map.addPopup( popup );
     22            map.addPopup(popup);
    2423        }
    25         function onFeatureUnselect(feature) {
    26             map.removePopup(feature.popup);
    27             feature.popup.destroy();
    28             feature.popup = null;
     24        function onFeatureUnselect(event) {
     25            var feature = event.feature;
     26            if(feature.popup) {
     27                map.removePopup(feature.popup);
     28                feature.popup.destroy();
     29                delete feature.popup;
     30            }
    2931        }
    3032
     
    8284
    8385            drawControls = {
    84                 polygon: new OpenLayers.Control.DrawFeature(markeri,
    85                             OpenLayers.Handler.Polygon),
    86                 select: new OpenLayers.Control.SelectFeature(markeri, {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect})
     86                polygon: new OpenLayers.Control.DrawFeature(markeri, OpenLayers.Handler.Polygon),
     87                select: new OpenLayers.Control.SelectFeature(markeri)
    8788            };
     89            markeri.events.on({
     90                "featureselected": onFeatureSelect,
     91                "featureunselected": onFeatureUnselect
     92            });
    8893
    8994            map.addControl(drawControls['select']);
Note: See TracChangeset for help on using the changeset viewer.