﻿
//
// Mapinfo class javascript
//

function Mapinfo(mapinfo) {
    var obj = this;
    $.each(mapinfo, function(key){
        obj[key] = mapinfo[key];
    });
}

Mapinfo.prototype.popupText = function() {
    var text = "";
    text += "<img src='/files/" + this.image + "' /><br />";
    text += "<string>" + this.title + "</string><br />";
    text += "" + this.description + "<br>";
    return text;
}

Mapinfo.prototype.gmarker = function() {
    var obj = this;
    if(this.locatex, this.locatey){
        var gicon = new GIcon();
        gicon.image = "/files/" + this.icon;
        gicon.iconSize = new GSize(18,22);
        gicon.iconAnchor = new GLatLng(22,9);
        gicon.infoWindowAnchor = new GLatLng(5,0);
        var marker = new GMarker(new GLatLng(this.locatey, this.locatex), { draggable: false, icon: gicon });
        GEvent.addListener(marker, "click", function(){

            marker.openInfoWindowHtml(obj.popupText());
        });
        return marker;
    }
}

