Don't display a popup or register events on a Text layer that doesn't have both title and description. Fixes #471.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@2820 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -126,7 +126,9 @@ OpenLayers.Layer.Text.prototype =
|
|||||||
var feature = new OpenLayers.Feature(this, location, data);
|
var feature = new OpenLayers.Feature(this, location, data);
|
||||||
this.features.push(feature);
|
this.features.push(feature);
|
||||||
var marker = feature.createMarker();
|
var marker = feature.createMarker();
|
||||||
marker.events.register('click', feature, this.markerClick);
|
if ((title != null) && (description != null)) {
|
||||||
|
marker.events.register('click', feature, this.markerClick);
|
||||||
|
}
|
||||||
this.addMarker(marker);
|
this.addMarker(marker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
}
|
}
|
||||||
function test_03_Layer_Text_events (t) {
|
function test_03_Layer_Text_events (t) {
|
||||||
t.plan( 4 );
|
t.plan( 4 );
|
||||||
layer = new OpenLayers.Layer.Text('Test Layer', { location: 'data_Layer_Text_textfile.txt'});
|
layer = new OpenLayers.Layer.Text('Test Layer', { location: 'data_Layer_Text_textfile_2.txt'});
|
||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
|
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
|
||||||
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||||
@@ -65,6 +65,26 @@
|
|||||||
t.eq(map.popups.length, 1, "1st popup gone, 2nd Popup opened correctly");
|
t.eq(map.popups.length, 1, "1st popup gone, 2nd Popup opened correctly");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function test_04_Layer_Text_events_nopopups (t) {
|
||||||
|
t.plan( 4 );
|
||||||
|
layer = new OpenLayers.Layer.Text('Test Layer', { location: 'data_Layer_Text_textfile.txt'});
|
||||||
|
var map = new OpenLayers.Map('map');
|
||||||
|
var baseLayer = new OpenLayers.Layer.WMS("Test Layer",
|
||||||
|
"http://octo.metacarta.com/cgi-bin/mapserv?",
|
||||||
|
{map: "/mapdata/vmap_wms.map", layers: "basic"});
|
||||||
|
map.addLayer(baseLayer);
|
||||||
|
map.addLayer(layer);
|
||||||
|
map.setCenter(new OpenLayers.LonLat(0,0),0);
|
||||||
|
var event = {};
|
||||||
|
t.delay_call( 1, function() {
|
||||||
|
t.ok(layer.markers[0].events, "First marker has an events object");
|
||||||
|
t.eq(layer.markers[0].events.listeners['click'].length, 0, "Marker events has one object");
|
||||||
|
layer.markers[0].events.triggerEvent('click', event);
|
||||||
|
t.eq(map.popups.length, 0, "no popup on first marker");
|
||||||
|
layer.markers[1].events.triggerEvent('click', event);
|
||||||
|
t.eq(map.popups.length, 0, "no popup on second marker");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function test_99_Layer_Text_destroy (t) {
|
function test_99_Layer_Text_destroy (t) {
|
||||||
t.plan( 1 );
|
t.plan( 1 );
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
point title description image
|
||||||
|
10,20 a b http://boston.openguides.org/markers/ORANGE.png
|
||||||
|
15,25 c d http://boston.openguides.org/markers/ORANGE.png
|
||||||
Reference in New Issue
Block a user