﻿NetGis = new Object();

NetGis.createObject = function (type) {
    return document.getElementById("NetGisClient").Content.services.createObject(type);
}


//ScriptCoordinate proxy
NetGis.Coordinate = function (x, y) {
    this.X = x;
    this.Y = y;
    this.getObject = function () {
        var source = NetGis.createObject("CoordinateType");
        source.X = this.X;
        source.Y = this.Y;
        return source;
    };
};

var NetGisQueryType = {
    Within : 1,
    Contains : 2,
    Intersects : 3,
    BBox :4
};

//ScriptMap proxy
NetGis.Map = function () {
    //ScriptingFacade tarafından oluşturulur
    this.source = document.getElementById("NetGisClient").Content.scriptMap;
    this.setCenter = function (coordinate, zoom) {
        this.source.SetCenter(coordinate.getObject(), zoom);
    } //returns void

    this.getCenter = function () {
        var c = this.source.GetCenter();
        return new NetGis.Coordinate(c.X, c.Y);
    } //returns NetGis.Coordinate

    this.getZoom = function () {
        return this.source.GetZoom();
    } //returns Integer

    this.setZoom = function (zoom) {
        this.source.SetZoom(zoom);
    } //returns void

    this.getCoordinate = function (onEnded) {
        this.source.GetCoordinate(onEnded);
    } //returns void

    this.getPolygon = function (onEnded) {
        this.source.GetPolygon(onEnded);
    } //return void

    this.getLineString = function (onEnded) {
        this.source.GetLineString(onEnded);
    } //return void

    this.query = function (queryType, fad, coordinate, onEnded) {
        if (queryType == NetGisQueryType.Contains)
            this.source.QueryContains(fad, coordinate.getObject(), onEnded);
    } //returns void

    this.addMarker = function (coordinate, layerName) {
        this.source.AddMarker(coordinate.getObject(), layerName);
    } //returns void

    this.clearMarkers = function (layerName) {
        this.source.ClearMarkers(layerName);
    } //returns void
}



