[OpenLayers-Users] Help for overwrite a object

Jan Tappenbeck osm at tappenbeck.net
Tue Mar 29 10:05:14 EDT 2011



hi !

i had to create a class-overwrite and i am a newbies of javascript.

i create following code until but it did not work correct and firebug 
did not say an error-message.

following had to define for the use in the class:

var coord = new Array();
coord['AEROSK600DNK'] = [54.891517, 10.412636];
coord['AGERSO600DNK'] = [55.211691, 11.197386];

var ferrylines = new Array();
ferrylines['AARHUS600DNK'] = ['KALUND600DNK','ODDENX600DNK'];
ferrylines['AEROSK600DNK'] = ['SVENDB600DNK'];

var ferrystatus = new Array();
ferrystatus['AARHUS600DNKKALUND600DNK'] = 1;
ferrystatus['AARHUS600DNKODDENX600DNK'] = 1;
ferrystatus['AEROSK600DNKSVENDB600DNK'] = 1;
ferrystatus['AGERSO600DNKSTIGSN600DNK'] = 1;

var ferryways = new Array();
ferryways['AARHUS600DNKKALUND600DNK'] = ['AARHUS600DNK','KALUND600DNK'];
ferryways['AARHUS600DNKODDENX600DNK'] = ['AARHUS600DNK','ODDENX600DNK'];

the class overwrite i create following:

OpenLayers.Layer.PopupMarker.Ferry = 
OpenLayers.Class(OpenLayers.Layer.PopupMarker,{
         coord: null,   // <<<<< meine Erweiterungen
         lines: null,
         status: null,
         ways: null,
         lyAnnual: null,
         lySaison: null

         initialize:function(name, db, coord, lines, status, ways, 
lyAnnual, lySaison, options){
                 
OpenLayers.Layer.PopupMarker.prototype.initialize.apply(this,[name, 
options]);
         this.db = db;
         },

i call the new funktion like:

   map.addLayer (new OpenLayers.Layer.PopupMarker.Ferry ("Port_P1", 
"ferry_portprio1_map1",
     {coord: coord, lines: ferrylines, status: ferrystatus, ways: 
ferryways, lyAnnual: map.vlayerAnnual,
         lySaison: map.vlayerSaison, minZoom: 8, zindex: 730, 
hideMarkerBelowMinZoom: true}));

the secound question: is the use of the variables in the class correct 
in the following source:

     destroyLines: function () {
        this.lyAnnual.destroyFeatures();
        this.lySaison.destroyFeatures();
     },

     // so ist der Aufruf in einer direkten JS-Funktion
     //function LinesFromPort (IdPortFrom, zoomflag) {

     LinesFromPort: function (IdPortFrom, zoomflag) {
        // darstellen der Ferry-Verbindungen in OL
        //  Entferne alte Features
        //  (hier abhängig von Parameter zur Demo)
        this.lyAnnual.destroyFeatures();
        this.lySaison.destroyFeatures();

        //  Lege ein Array für die Features an
        var features = [];
        // für das Aufzoomen der Fährstrecken
        var bounds = new OpenLayers.Bounds  ();

        // Schleife mit den einzelnen Ferry-Verbindungen
        // ... durchlaufen der Zielhäfen von einem Ausgangshafen
        for ( i in this.lines[IdPortFrom]){
           var Idlines = this.lines[IdPortFrom][i];
           //ID für die Ferryway
           var IdFerryways = IdPortFrom+Idlines;
           // Wie wird die Linie bedient 0... ganz (default) 1... saison
           var LineStatus = 0;
           if (this.status[IdFerryways])

can anybody help me ..... ??

regards Jan :-)
(sorry for my worst english)



More information about the Users mailing list