Changeset 253
- Timestamp:
- Apr 20, 2010, 9:07:14 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
linux-za-sve/karta/frontend/js/LinuxMap.js
r222 r253 6 6 var map, layer, drawControls, selectControl, selectedFeature;; //complex object of type OpenLayers.Map 7 7 8 function onPopupClose( feature) {9 selectControl.unselect(selectedFeature);8 function onPopupClose(evt) { 9 drawControls['select'].unselectAll(); 10 10 } 11 function onFeatureSelect( feature) {12 selectedFeature =feature;11 function onFeatureSelect(event) { 12 var feature = event.feature; 13 13 OpenLayers.Popup.FramedCloud.prototype.autoSize = false; 14 var content = "<h2>"+feature.attributes.title + "</h2>" + feature.attributes.description; 14 15 15 16 popup = new OpenLayers.Popup.FramedCloud("marker", 16 17 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); 21 21 feature.popup = popup; 22 popup.feature = feature; 23 map.addPopup( popup ); 22 map.addPopup(popup); 24 23 } 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 } 29 31 } 30 32 … … 82 84 83 85 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) 87 88 }; 89 markeri.events.on({ 90 "featureselected": onFeatureSelect, 91 "featureunselected": onFeatureUnselect 92 }); 88 93 89 94 map.addControl(drawControls['select']);
Note: See TracChangeset
for help on using the changeset viewer.