function CustomGetTileUrl(c, z)
{
  //alert(c);
  if ((c.x >= 9560 && c.x <= 9582 && c.y >= 5559 && c.y<= 5580) ||
      (c.x >= 4776 && c.x <= 4793 && c.y >= 2776 && c.y<= 2793) ||
      (c.x >= 2386 && c.x <= 2399 && c.y >= 1386 && c.y<= 1398) ||
      (c.x >= 1193 && c.x <= 1199 && c.y >= 693  && c.y<= 699)  ||
      (c.x >= 597 && c.x <= 599 && c.y >= 347 && c.y<= 349)) {
        var xMap = "/images/map/"+(15-z)+"/slice_"+c.y+"_"+c.x+".png";
  }
  else
  {
    var xMap = "/images/map/empty.png";
  }
    return xMap;
}

function mapInit()
{
  if (GBrowserIsCompatible())
  {
    map = new GMap2(document.getElementById("map"));

    /*
    var polyOptions = {geodesic:true};
    var polyline = new GPolyline([
        new GLatLng(49.7991067, 30.3420938),
        new GLatLng(55.1699849, -20.944496)
    ], "#ff0000", 10, 1, polyOptions);
    map.addOverlay(polyline);
    */

    map.addControl(new GLargeMapControl());

    var tilelayers = [new GTileLayer(new GCopyrightCollection())];
        tilelayers[0].getTileUrl = CustomGetTileUrl;
        tilelayers[0].isPng = function() {return true;};

    var xnetmap = new GMapType(tilelayers,
                    new GMercatorProjection(15), "Xnet", {
                            maxResolution: 14,
                            minResolution: 10,
                            errorMessage: "Область вне карты",
                            linkColor: "#269AC0"
                        });

    map.addMapType(xnetmap);
    map.setCenter(new GLatLng(49.7991067, 30.3420938), 10, xnetmap);

    var bounds = map.getBounds();
    var zoom = 15-map.getBoundsZoomLevel(bounds);
    var southWest = bounds.getSouthWest();
    var northEast = bounds.getNorthEast();
    var lngSpan = northEast.lng() - southWest.lng();
    var latSpan = northEast.lat() - southWest.lat();

    /*
    // Создать иконку Ромчика ////////////////////////////////////////////////////////////////////////////////////
    if (zoom == 5)
    {
        var romaIcon = new GIcon(G_DEFAULT_ICON);
        romaIcon.image = "/images/map/roma_text.png";
        romaIcon.iconSize = new GSize(30, 12);
        romaIcon.shadowSize = new GSize(0, 0);
        romaIcon.infoWindowAnchor = new GPoint(9, 2);
        markerOptions = { icon:romaIcon };
        var latlng = new GLatLng(southWest.lat() + latSpan * 0.5276457, southWest.lng() + lngSpan * 0.6176743);
    }
    if (zoom == 4)
    {
        var romaIcon = new GIcon(G_DEFAULT_ICON);
        romaIcon.image = "/images/map/roma.png";
        romaIcon.iconSize = new GSize(25, 25);
        romaIcon.shadowSize = new GSize(0, 0);
        romaIcon.infoWindowAnchor = new GPoint(9, 2);
        markerOptions = { icon:romaIcon };
        var latlng = new GLatLng(southWest.lat() + latSpan * 0.6046457, southWest.lng() + lngSpan * 1.0076743);
    }
    map.addOverlay(new GMarker(latlng, markerOptions));
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////
    */
  }
  else
  {
    alert("Sorry, the Google Maps API is not compatible with this browser");
  }
}