OpenLayers OpenLayers

Changeset 372

Show
Ignore:
Timestamp:
05/25/06 14:03:15 (3 years ago)
Author:
euzuro
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Feature/MetaCarta.js

    r292 r372  
     1/**  
     2 * @class 
     3 */ 
     4MCFeature = Class.create(); 
     5MCFeature.prototype = { 
    16 
     7    /** @type String */ 
     8    id: "", 
    29 
    3 /** Parse a feature from an XML node 
    4 * MC specific at the moment 
    5 */ 
    6 OpenLayers.Feature.MetaCarta = Class.create(); 
    7 OpenLayers.Feature.MetaCarta.prototype= { 
    8  
    9     // Object 
    10     listeners:null, 
    11  
    12     // ol.Size 
     10    /** @type OpenLayers.Size */ 
    1311    size:null, 
    1412     
    15     // ol.LatLon 
    16     _latlon:null, 
     13    /** @type OpenLayers.LonLat */ 
     14    lonlat:null, 
    1715 
    18     // str         
    19     id:"", 
    20     fid:null, 
    21     srsName:null, 
    22     title:null, 
    23     location:null, 
    24     docurl:null, 
    25     extract:null, 
    26     geoExtract:null, 
    27     relevance:null, 
    28     geoRelevance:null, 
    29     markerImage:null, 
     16    /** @type String */ 
     17    markerImage: "", 
     18     
     19    /** @type String */ 
     20    srsName: "", 
    3021 
    31     initialize: function(fNode) { 
    32         this.listeners = new Object(); 
     22    /** @type String */ 
     23    title: "", 
    3324 
    34         var docpt = OpenLayers.Util.getNodes(fNode, "docpoint")[0]; 
    35         this.fid =  docpt.getAttribute('fid'); 
    36         this.id = this.fid; 
     25    /** @type String */ 
     26    location: "", 
     27 
     28    /** @type String */ 
     29    docurl: "", 
     30 
     31    /** @type String */ 
     32    extract: "", 
     33 
     34    /** @type String */ 
     35    geoExtract: "", 
     36 
     37    /** @type String */ 
     38    relevance: "", 
     39 
     40    /** @type String */ 
     41    geoRelevance: "", 
     42 
     43    /** 
     44     * @constructor 
     45     *  
     46     * @param {XMLNode} node 
     47     */ 
     48    initialize: function(node) { 
     49 
     50        var docpt = OpenLayers.Util.getNodes(node, "docpoint")[0]; 
     51        this.id = docpt.getAttribute('fid'); 
    3752     
    38         var node = OpenLayers.Util.getNodes(docpt, "position")[0]; 
    39         node = OpenLayers.Util.getNodes(node, "gml:Point")[0]; 
    40         this.srsName = node.getAttribute('srsName'); 
    41         var temp = OpenLayers.Util.getTagText(node, "gml:coordinates"); 
    42         this._latlon = ol.LatLon.fromString(temp); 
     53        var position = OpenLayers.Util.getNodes(docpt, "position")[0]; 
     54        var point = OpenLayers.Util.getNodes(position, "gml:Point")[0]; 
     55        this.srsName = point.getAttribute('srsName'); 
     56        var coords = OpenLayers.Util.getTagText(point, "gml:coordinates"); 
     57        this.lonlat = OpenLayers.LonLat.fromString(coords); 
    4358         
    4459        this.title = OpenLayers.Util.getTagText(docpt, "title"); 
     
    5469    }, 
    5570 
     71    /** 
     72     *  
     73     */ 
    5674    destroy: function() { 
    57         this.listeners = null; 
    58         this.fid = null; 
    59         this.id = null; 
    60         this.srsName = null; 
    61         this._latlon = null; 
    62         this.title = null; 
    63         this.location = null; 
    64         this.docurl = null; 
    65         this.extract = null; 
    66         this.geoExtract = null; 
    67         this.relevance = null; 
    68         this.geoRelevance = null; 
    69         this.markerImage = null; 
    70         this.size = null; 
    7175    }, 
    7276     
     77 
     78    /** 
     79     * @returns String version of this MCFeature, for easy debugging 
     80     * @type String 
     81     */ 
    7382    toString:function() { 
    74         var s = this.title + " relevance:" + this.relevance +  
     83        return this.title + " relevance:" + this.relevance +  
    7584                    " [" + this.geoRelevance + "]"; 
    7685        s += " Fid [" + this.fid + "] @ " + this._latlon.toString(); 
    7786        s += " Location [" + this.geoExtract + "]"; 
    78         return s; 
    7987    }, 
    8088 
    81     /* MARKER DATA INTERFACE FUNCTIONS: 
    82     * 
    83     *  getLatLon(), getImage()  
    84     * 
    85     */ 
    86       
    8789    /** 
    88     * ret(ol.Point) 
    89     */ 
    90     getLatLon:function() { return this._latlon.copyOf(); }, 
     90     * @param {OpenLayers.Marker} marker 
     91     */ 
     92    loadEvents: function(marker) { 
     93        marker.events.register("mousedown", marker, this.onMarkerMouseDown); 
     94 
     95// this.onMarkerMouseDown.bindAsEventListener(this));                 
     96    }, 
    9197 
    9298 
    93    /** 
    94     * ret(ol.Point) 
    95     */ 
    96     getImage:function() { return this.markerImage; }, 
     99    /** 
     100     * @param {Event} evt 
     101     */ 
     102    onMarkerMouseDown: function(evt) { 
     103        alert("yo!"); 
     104    }, 
    97105 
    98   
    99     /** html content based on feature information 
    100     * 
    101     * ret(str):  
    102     */ 
     106    /**  
     107     * @returns HTML content based on feature information - for use with Popups 
     108     * @type String 
     109     */ 
    103110    getContentHTML:function() { 
    104      
     111 
    105112        var contentHTML = ""; 
    106113         
     
    136143    }, 
    137144 
    138     /** html content based on feature information 
    139     * 
    140     * ret(str):  
    141     */ 
     145    /**  
     146    * @returns HTML content based on feature information- for use with ListDiv 
     147     * @type String 
     148    */ 
    142149    getDivListHTML:function() { 
    143150     
    144151        var divHTML = ''; 
    145152       
    146         divHTML += '<div id="' + this.fid + '">'; 
     153        divHTML += '<div id="' + this.id + '">'; 
    147154        divHTML += '<a href="' + this.docurl + '">'; 
    148155        divHTML +=     this.title; 
     
    154161    }, 
    155162 
    156     ///////////////////////////////// 
    157     who:function(){return ("Feature.js");}  //last 
    158      
     163  /** @final @type String */ 
     164  CLASS_NAME: "MCFeature"   
    159165}; 
    160166