Update MetaCarta.js to new Feature architecture. Soon this is going to be removed from here and renamed MCFeature.js

git-svn-id: http://svn.openlayers.org/trunk/openlayers@372 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-05-25 18:03:15 +00:00
parent 3440da2c5e
commit 621d7074f2

View File

@@ -1,45 +1,60 @@
/**
* @class
*/
MCFeature = Class.create();
MCFeature.prototype = {
/** @type String */
id: "",
/** Parse a feature from an XML node
* MC specific at the moment
*/
OpenLayers.Feature.MetaCarta = Class.create();
OpenLayers.Feature.MetaCarta.prototype= {
// Object
listeners:null,
// ol.Size
/** @type OpenLayers.Size */
size:null,
// ol.LatLon
_latlon:null,
/** @type OpenLayers.LonLat */
lonlat:null,
// str
id:"",
fid:null,
srsName:null,
title:null,
location:null,
docurl:null,
extract:null,
geoExtract:null,
relevance:null,
geoRelevance:null,
markerImage:null,
initialize: function(fNode) {
this.listeners = new Object();
var docpt = OpenLayers.Util.getNodes(fNode, "docpoint")[0];
this.fid = docpt.getAttribute('fid');
this.id = this.fid;
/** @type String */
markerImage: "",
var node = OpenLayers.Util.getNodes(docpt, "position")[0];
node = OpenLayers.Util.getNodes(node, "gml:Point")[0];
this.srsName = node.getAttribute('srsName');
var temp = OpenLayers.Util.getTagText(node, "gml:coordinates");
this._latlon = ol.LatLon.fromString(temp);
/** @type String */
srsName: "",
/** @type String */
title: "",
/** @type String */
location: "",
/** @type String */
docurl: "",
/** @type String */
extract: "",
/** @type String */
geoExtract: "",
/** @type String */
relevance: "",
/** @type String */
geoRelevance: "",
/**
* @constructor
*
* @param {XMLNode} node
*/
initialize: function(node) {
var docpt = OpenLayers.Util.getNodes(node, "docpoint")[0];
this.id = docpt.getAttribute('fid');
var position = OpenLayers.Util.getNodes(docpt, "position")[0];
var point = OpenLayers.Util.getNodes(position, "gml:Point")[0];
this.srsName = point.getAttribute('srsName');
var coords = OpenLayers.Util.getTagText(point, "gml:coordinates");
this.lonlat = OpenLayers.LonLat.fromString(coords);
this.title = OpenLayers.Util.getTagText(docpt, "title");
this.location = OpenLayers.Util.getTagText(docpt, "locationName");
@@ -53,55 +68,47 @@ OpenLayers.Feature.MetaCarta.prototype= {
this.size = new ol.Size(20, 25); // TODO: Fix this hard coded value.
},
/**
*
*/
destroy: function() {
this.listeners = null;
this.fid = null;
this.id = null;
this.srsName = null;
this._latlon = null;
this.title = null;
this.location = null;
this.docurl = null;
this.extract = null;
this.geoExtract = null;
this.relevance = null;
this.geoRelevance = null;
this.markerImage = null;
this.size = null;
},
/**
* @returns String version of this MCFeature, for easy debugging
* @type String
*/
toString:function() {
var s = this.title + " relevance:" + this.relevance +
return this.title + " relevance:" + this.relevance +
" [" + this.geoRelevance + "]";
s += " Fid [" + this.fid + "] @ " + this._latlon.toString();
s += " Location [" + this.geoExtract + "]";
return s;
},
/* MARKER DATA INTERFACE FUNCTIONS:
*
* getLatLon(), getImage()
*
*/
/**
* ret(ol.Point)
*/
getLatLon:function() { return this._latlon.copyOf(); },
* @param {OpenLayers.Marker} marker
*/
loadEvents: function(marker) {
marker.events.register("mousedown", marker, this.onMarkerMouseDown);
// this.onMarkerMouseDown.bindAsEventListener(this));
},
/**
* ret(ol.Point)
*/
getImage:function() { return this.markerImage; },
/**
* @param {Event} evt
*/
onMarkerMouseDown: function(evt) {
alert("yo!");
},
/** html content based on feature information
*
* ret(str):
*/
/**
* @returns HTML content based on feature information - for use with Popups
* @type String
*/
getContentHTML:function() {
var contentHTML = "";
contentHTML += "<div style='margin: 0.25em'>"
@@ -135,15 +142,15 @@ OpenLayers.Feature.MetaCarta.prototype= {
return contentHTML;
},
/** html content based on feature information
*
* ret(str):
*/
/**
* @returns HTML content based on feature information- for use with ListDiv
* @type String
*/
getDivListHTML:function() {
var divHTML = '';
divHTML += '<div id="' + this.fid + '">';
divHTML += '<div id="' + this.id + '">';
divHTML += '<a href="' + this.docurl + '">';
divHTML += this.title;
divHTML += '</a><div>';
@@ -153,9 +160,8 @@ OpenLayers.Feature.MetaCarta.prototype= {
return divHTML;
},
/////////////////////////////////
who:function(){return ("Feature.js");} //last
/** @final @type String */
CLASS_NAME: "MCFeature"
};