OpenLayers OpenLayers

Ticket #1135: Text_with_any_attribute.diff

File Text_with_any_attribute.diff, 2.7 kB (added by jachym, 1 year ago)

OpenLayers.Layer.Text with any, in the input textfile available, attribute

  • lib/OpenLayers/Layer/Text.js

    old new  
    9191                    var vals = currLine.split('\t'); 
    9292                    var location = new OpenLayers.LonLat(0,0); 
    9393                    var title, url, description; 
     94                    var otherAttributes = {}; 
    9495                    var icon, iconSize, iconOffset, overflow; 
    9596                    var set = false; 
    9697                    for (var valIndex = 0; valIndex < vals.length; valIndex++) { 
     
    125126                                description = vals[valIndex]; 
    126127                            } else if (columns[valIndex] == 'overflow') { 
    127128                                overflow = vals[valIndex]; 
    128                             }     
     129                            } else { 
     130                                otherAttributes[columns[valIndex]] = vals[valIndex];  
     131                            } 
    129132                        } 
    130133                    } 
    131134                    if (set) { 
     
    150153                      } 
    151154                       
    152155                      data['overflow'] = overflow || "auto";  
     156 
     157                      // add all other attributes 
     158                      for (var key in otherAttributes) { 
     159                          data[key] = otherAttributes[key]; 
     160                      } 
    153161                       
    154162                      var feature = new OpenLayers.Feature(this, location, data); 
    155163                      this.features.push(feature); 
  • tests/data_Layer_Text_textfile.txt

    old new  
    1 point   image 
    2 10,20   http://boston.openguides.org/markers/ORANGE.png 
    3 15,25   http://boston.openguides.org/markers/ORANGE.png 
     1point   id image 
     210,20   http://boston.openguides.org/markers/ORANGE.png 
     315,25   http://boston.openguides.org/markers/ORANGE.png 
  • examples/textfile.txt

    old new  
    1 point title   description icon 
    2 10,20 my orange title my orange description    
    3 2,4   my aqua title   my aqua description  
    4 42,-71    my purple title my purple description<br/>is great. http://www.openlayers.org/api/img/zoom-world-mini.png 
     1id point  title   description icon 
     21  10,20  my orange title my orange description    
     32  2,4    my aqua title   my aqua description  
     442,-71 my purple title my purple description<br/>is great. http://www.openlayers.org/api/img/zoom-world-mini.png