/*
* Google layer using Google Maps API
*/
//(function (google, L) {
L.Google = L.Layer.extend({
includes: L.Mixin.Events,
options: {
minZoom: 0,
maxZoom: 18,
tileSize: 256,
subdomains: 'abc',
errorTileUrl: '',
attribution: '',
opacity: 1,
continuousWorld: false,
noWrap: false,
mapOptions: {
backgroundColor: '#dddddd'
}
},
// Possible types: SATELLITE, ROADMAP, HYBRID, TERRAIN
initialize: function(type, options) {
L.Util.setOptions(this, options);
this._ready = google.maps.Map != undefined;
if (!this._ready) L.Google.asyncWait.push(this);
this._type = type || 'SATELLITE';
},
onAdd: function(map, insertAtTheBottom) {
this._map = map;
this._insertAtTheBottom = insertAtTheBottom;
// create a container div for tiles
this._initContainer();
this._initMapObject();
// set up events
map.on('viewreset', this._resetCallback, this);
this._limitedUpdate = L.Util.throttle(this._update, 150, this);
map.on('move', this._update, this);
map.on('zoomanim', this._handleZoomAnim, this);
//20px instead of 1em to avoid a slight overlap with google's attribution
map._controlCorners['bottomright'].style.marginBottom = "20px";
this._reset();
this._update();
},
onRemove: function(map) {
this._map._container.removeChild(this._container);
//this._container = null;
this._map.off('viewreset', this._resetCallback, this);
this._map.off('move', this._update, this);
this._map.off('zoomanim', this._handleZoomAnim, this);
map._controlCorners['bottomright'].style.marginBottom = "0em";
//this._map.off('moveend', this._update, this);
},
getAttribution: function() {
return this.options.attribution;
},
setOpacity: function(opacity) {
this.options.opacity = opacity;
if (opacity < 1) {
L.DomUtil.setOpacity(this._container, opacity);
}
},
setElementSize: function(e, size) {
e.style.width = size.x + "px";
e.style.height = size.y + "px";
},
_initContainer: function() {
var tilePane = this._map._container,
first = tilePane.firstChild;
if (!this._container) {
this._container = L.DomUtil.create('div', 'leaflet-google-layer leaflet-top leaflet-left');
this._container.id = "_GMapContainer_" + L.Util.stamp(this);
this._container.style.zIndex = "auto";
}
tilePane.insertBefore(this._container, first);
this.setOpacity(this.options.opacity);
this.setElementSize(this._container, this._map.getSize());
},
_initMapObject: function() {
if (!this._ready) return;
this._google_center = new google.maps.LatLng(0, 0);
var map = new google.maps.Map(this._container, {
center: this._google_center,
zoom: 0,
tilt: 0,
mapTypeId: google.maps.MapTypeId[this._type],
disableDefaultUI: true,
keyboardShortcuts: false,
draggable: false,
disableDoubleClickZoom: true,
scrollwheel: false,
streetViewControl: false,
styles: this.options.mapOptions.styles,
backgroundColor: this.options.mapOptions.backgroundColor
});
var _this = this;
this._reposition = google.maps.event.addListenerOnce(map, "center_changed",
function() { _this.onReposition(); });
this._google = map;
google.maps.event.addListenerOnce(map, "idle",
function() { _this._checkZoomLevels(); });
},
_checkZoomLevels: function() {
//setting the zoom level on the Google map may result in a different zoom level than the one requested
//(it won't go beyond the level for which they have data).
// verify and make sure the zoom levels on both Leaflet and Google maps are consistent
if (this._google.getZoom() !== this._map.getZoom()) {
//zoom levels are out of sync. Set the leaflet zoom level to match the google one
this._map.setZoom( this._google.getZoom() );
}
},
_resetCallback: function(e) {
this._reset(e.hard);
},
_reset: function(clearOldContainer) {
this._initContainer();
},
_update: function(e) {
if (!this._google) return;
this._resize();
var center = e && e.latlng ? e.latlng : this._map.getCenter();
var _center = new google.maps.LatLng(center.lat, center.lng);
this._google.setCenter(_center);
this._google.setZoom(this._map.getZoom());
this._checkZoomLevels();
//this._google.fitBounds(google_bounds);
},
_resize: function() {
var size = this._map.getSize();
if (this._container.style.width == size.x &&
this._container.style.height == size.y)
return;
this.setElementSize(this._container, size);
this.onReposition();
},
_handleZoomAnim: function (e) {
var center = e.center;
var _center = new google.maps.LatLng(center.lat, center.lng);
this._google.setCenter(_center);
this._google.setZoom(e.zoom);
},
onReposition: function() {
if (!this._google) return;
google.maps.event.trigger(this._google, "resize");
}
});
L.Google.asyncWait = [];
L.Google.asyncInitialize = function() {
var i;
for (i = 0; i < L.Google.asyncWait.length; i++) {
var o = L.Google.asyncWait[i];
o._ready = true;
if (o._container) {
o._initMapObject();
o._update();
}
}
L.Google.asyncWait = [];
};
//})(window.google, L)
var zm = 11;
var cent = [51.2162, 24.7096];
if(window.location.pathname == '/bigcmap')
{
zm = 13;
cent = [51.201505700935925, 24.67975616455078];
}
var osm = new L.TileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{'minZoom':0,'maxZoom':18,'tileSize':256,'subdomains':'abc','attribution':'Map data © OpenStreetMap contributors, CC-BY-SA'});
//var osmt = new L.TileLayer('http://openmapsurfer.uni-hd.de/tiles/hybrid/?x={x}&y={y}&z={z}',{'minZoom':0,'maxZoom':18,'tileSize':256,'subdomains':'abc','attribution':'Map data © OpenStreetMap contributors, CC-BY-SA'});
var osmt = new L.TileLayer('https://c.sm.mapstack.stamen.com/toner-hybrid/{z}/{x}/{y}.png',{'minZoom':0,'maxZoom':18,'tileSize':256,'subdomains':'abc','attribution':'Map data © OpenStreetMap contributors, CC-BY-SA'});
//var osmt = new L.TileLayer('http://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}',{'minZoom':0,'maxZoom':18,'tileSize':256,'subdomains':'abc','attribution':'Map data © OpenStreetMap contributors, CC-BY-SA'});
osmt.setZIndex(2100);
var ggl = new L.Google();
var ggl2 = new L.Google();
//var ggl = new L.Yandex("satellite");
//var ggl2 = new L.Yandex("satellite");
var wms = new L.tileLayer.wms("https://my.uainet.net/cgi-bin/qgis_mapserv.fcgi?map=/var/www/coverage.qgs", {
layers: 'coverage_for_site',
format: 'image/png',
transparent: true,
});
wms.setZIndex(2000);
var wms1 = new L.tileLayer.wms("https://my.uainet.net/cgi-bin/qgis_mapserv.fcgi?map=/var/www/coverage.qgs", {
layers: 'coverage_for_site',
format: 'image/png',
transparent: true,
});
wms1.setZIndex(2000);
var wms2 = new L.tileLayer.wms("https://my.uainet.net/cgi-bin/qgis_mapserv.fcgi?map=/var/www/coverage.qgs", {
layers: 'coverage_for_site',
format: 'image/png',
transparent: true,
});
wms2.setZIndex(2000);
var mxd = L.layerGroup([ggl2,wms,osmt]);//osmt
var osmw = L.layerGroup([osm,wms1]);
var gg = L.layerGroup([wms2,ggl]);
var map = L.map('map',{
center: cent,
zoom: zm,
layers: [osmw]
});
var bm = {
"Гібрид":mxd,
"OpenstreetMap": osmw,
"Cупутник": gg
};
L.control.layers(bm).addTo(map);
var legend = L.control({position: 'bottomright'});
legend.onAdd = function (map) {
var div = L.DomUtil.create('div', 'mapinfo legend');
div.innerHTML +=
' Існуюче покриття
' +
' Заплановане покриття
';
return div;
};
legend.addTo(map);
var myIcon = L.icon({
iconUrl: '/themes/uainet/images/marker-icon.png',
iconSize: [25,41],
iconAnchor: [12, 40],
popupAnchor: [-3, -76],
shadowUrl: '/themes/uainet/images/marker-shadow.png',
shadowSize: [41,41],
shadowAnchor: [25, 41]
});
var ll;
var mark = null;
map.on('click',function(e){
ll = e.latlng;
if(mark == null)
{
mark = new L.marker(e.latlng,{icon:myIcon,zIndexOffset:3000,draggable:true}).bindTooltip("",
{
permanent: false,
direction: 'bottom'
}
).addTo(map);
mark.on('drag',function(){ll = mark.getLatLng();});
mark.on('dragend',markdrag);
place_checked();
}else{
mark.setLatLng(e.latlng);
mark.update();
}
markdrag();
});
function cfriendFormUid(data, textStatus)
{
if(data.error != undefined)
{
$('#pconnect .errorwrap').html('
Друзів можуть приводити лише існуючі абоненти UAinet
'); }else{ if(data.uid != undefined && data.uid != '') { $('#friendtbl').append('