Working text layer with popups! woohoo! parseText suffered a reindentation, so not as much changed here as it looks like.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@424 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -36,8 +36,8 @@ OpenLayers.Layer.Text.prototype =
|
||||
} else {
|
||||
var vals = currLine.split('\t');
|
||||
var location = new OpenLayers.LonLat(0,0);
|
||||
var title = ""; var description = "";
|
||||
var icon = new OpenLayers.Icon('http://boston.openguides.org/markers/AQUA.png',new OpenLayers.Size(10,17));
|
||||
var title; var url;
|
||||
var icon, iconSize, iconOffset;
|
||||
var set = false;
|
||||
for (var valIndex = 0; valIndex < vals.length; valIndex++) {
|
||||
if (vals[valIndex]) {
|
||||
@@ -54,27 +54,45 @@ OpenLayers.Layer.Text.prototype =
|
||||
set = true;
|
||||
} else if (columns[valIndex] == 'title')
|
||||
title = vals[valIndex];
|
||||
else if (columns[valIndex] == 'image')
|
||||
icon.url = vals[valIndex];
|
||||
else if (columns[valIndex] == 'title')
|
||||
else if (columns[valIndex] == 'image' ||
|
||||
columns[valIndex] == 'icon')
|
||||
url = vals[valIndex];
|
||||
else if (columns[valIndex] == 'iconSize') {
|
||||
var size = vals[valIndex].split(',');
|
||||
iconSize = new OpenLayers.Size(parseFloat(size[0]),
|
||||
parseFloat(size[1]));
|
||||
} else if (columns[valIndex] == 'iconOffset') {
|
||||
var offset = vals[valIndex].split(',');
|
||||
iconOffset = new OpenLayers.Pixel(parseFloat(offset[0]),
|
||||
parseFloat(offset[1]));
|
||||
} else if (columns[valIndex] == 'title') {
|
||||
title = vals[valIndex];
|
||||
else if (columns[valIndex] == 'description') {
|
||||
} else if (columns[valIndex] == 'description') {
|
||||
description = vals[valIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (set) {
|
||||
var marker = new OpenLayers.Marker(location, icon);
|
||||
var popup = new OpenLayers.Popup(null, location, null, '<h2>'+title+'</h2><p>'+description+'</p>');
|
||||
marker.events.register('click', this, function(evt) { this.map.addPopup(popup); Event.stop(evt); } ); //this.map.addPopup(popup); });
|
||||
var data = {};
|
||||
data['iconURL'] = url;
|
||||
data['iconSize'] = iconSize;
|
||||
data['iconOffset'] = iconOffset;
|
||||
data['popupContentHTML'] = '<h2>'+title+'</h2><p>'+description+'</p>';
|
||||
var feature = new OpenLayers.Feature(this, location, data);
|
||||
var marker = feature.createMarker();
|
||||
marker.events.register('click', feature, this.markerClick);
|
||||
this.addMarker(marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
testFunction: function() {
|
||||
alert('tesT');
|
||||
markerClick: function(evt) {
|
||||
for(var i=0; i < this.layer.map.popups.length; i++) {
|
||||
this.layer.map.removePopup(this.layer.map.popups[i]);
|
||||
}
|
||||
this.layer.map.addPopup(this.createPopup());
|
||||
Event.stop(evt);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user