Merge remote-tracking branch 'upstream/master' into to-push

This commit is contained in:
Mike Castle 2013-11-22 23:42:13 -08:00
commit a4a90c9fd1
10 changed files with 565 additions and 441 deletions

View File

@ -114,9 +114,22 @@ window.setupMap = function() {
//var mqSatOpt = {attribution: 'Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency', mazZoom: 18, subdomains: mqSubdomains};
//var mqSat = new L.TileLayer('http://{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg',mqSatOpt);
var ingressGMapOptions = {
backgroundColor: '#0e3d4e', //or #dddddd ? - that's the Google tile layer default
styles: [
{ featureType:"all", elementType:"all",
stylers: [{visibility:"on"}, {hue:"#131c1c"}, {saturation:"-50"}, {invert_lightness:true}] },
{ featureType:"water", elementType:"all",
stylers: [{visibility:"on"}, {hue:"#005eff"}, {invert_lightness:true}] },
{ featureType:"poi", stylers:[{visibility:"off"}]},
{ featureType:"transit", elementType:"all", stylers:[{visibility:"off"}] }
]
};
var views = [
/*0*/ mqMap,
/*1*/ new L.Google('INGRESS',{maxZoom:20}),
/*1*/ new L.Google('ROADMAP',{maxZoom:20, mapOptions:ingressGMapOptions}),
/*2*/ new L.Google('ROADMAP',{maxZoom:20}),
/*3*/ new L.Google('SATELLITE',{maxZoom:20}),
/*4*/ new L.Google('HYBRID',{maxZoom:20}),
@ -581,7 +594,7 @@ try { console.log('Loading included JS now'); } catch(e) {}
@@INCLUDERAW:external/L.Geodesic.js@@
// modified version of https://github.com/shramov/leaflet-plugins. Also
// contains the default Ingress map style.
@@INCLUDERAW:external/leaflet_google.js@@
@@INCLUDERAW:external/Google.js@@
@@INCLUDERAW:external/autolink.js@@
try { console.log('done loading included JS'); } catch(e) {}

138
external/Bing.js vendored Normal file
View File

@ -0,0 +1,138 @@
L.BingLayer = L.TileLayer.extend({
options: {
subdomains: [0, 1, 2, 3],
type: 'Aerial',
attribution: 'Bing',
culture: ''
},
initialize: function(key, options) {
L.Util.setOptions(this, options);
this._key = key;
this._url = null;
this.meta = {};
this.loadMetadata();
},
tile2quad: function(x, y, z) {
var quad = '';
for (var i = z; i > 0; i--) {
var digit = 0;
var mask = 1 << (i - 1);
if ((x & mask) != 0) digit += 1;
if ((y & mask) != 0) digit += 2;
quad = quad + digit;
}
return quad;
},
getTileUrl: function(p, z) {
var z = this._getZoomForUrl();
var subdomains = this.options.subdomains,
s = this.options.subdomains[Math.abs((p.x + p.y) % subdomains.length)];
return this._url.replace('{subdomain}', s)
.replace('{quadkey}', this.tile2quad(p.x, p.y, z))
.replace('http:', document.location.protocol)
.replace('{culture}', this.options.culture);
},
loadMetadata: function() {
//MODIFIED: use browser sessionStorage, if available, to cache the metadata
var _this = this;
var cbid = '_bing_metadata_' + L.Util.stamp(this);
var cachedMetadataKey = '_Leaflet_Bing_metadata_'+this.options.type;
try {
if (sessionStorage[cachedMetadataKey]) {
this.meta = JSON.parse(sessionStorage[cachedMetadataKey]);
this.initMetadata();
return;
}
} catch(e) {}
window[cbid] = function (meta) {
_this.meta = meta;
window[cbid] = undefined;
var e = document.getElementById(cbid);
e.parentNode.removeChild(e);
if (meta.errorDetails) {
if (window.console) console.log("Leaflet Bing Plugin Error - Got metadata: " + meta.errorDetails);
return;
}
try {
sessionStorage[cachedMetadataKey] = JSON.stringify(meta);
} catch(e) {}
_this.initMetadata();
};
var url = document.location.protocol + "//dev.virtualearth.net/REST/v1/Imagery/Metadata/" + this.options.type + "?include=ImageryProviders&jsonp=" + cbid + "&key=" + this._key;
var script = document.createElement("script");
script.type = "text/javascript";
script.src = url;
script.id = cbid;
document.getElementsByTagName("head")[0].appendChild(script);
},
initMetadata: function() {
var r = this.meta.resourceSets[0].resources[0];
this.options.subdomains = r.imageUrlSubdomains;
this._url = r.imageUrl;
this._providers = [];
if (r.imageryProviders) {
for (var i = 0; i < r.imageryProviders.length; i++) {
var p = r.imageryProviders[i];
for (var j = 0; j < p.coverageAreas.length; j++) {
var c = p.coverageAreas[j];
var coverage = {zoomMin: c.zoomMin, zoomMax: c.zoomMax, active: false};
var bounds = new L.LatLngBounds(
new L.LatLng(c.bbox[0]+0.01, c.bbox[1]+0.01),
new L.LatLng(c.bbox[2]-0.01, c.bbox[3]-0.01)
);
coverage.bounds = bounds;
coverage.attrib = p.attribution;
this._providers.push(coverage);
}
}
}
this._update();
},
_update: function() {
if (this._url == null || !this._map) return;
this._update_attribution();
L.TileLayer.prototype._update.apply(this, []);
},
_update_attribution: function() {
var bounds = this._map.getBounds();
var zoom = this._map.getZoom();
for (var i = 0; i < this._providers.length; i++) {
var p = this._providers[i];
if ((zoom <= p.zoomMax && zoom >= p.zoomMin) &&
bounds.intersects(p.bounds)) {
if (!p.active && this._map.attributionControl)
this._map.attributionControl.addAttribution(p.attrib);
p.active = true;
} else {
if (p.active && this._map.attributionControl)
this._map.attributionControl.removeAttribution(p.attrib);
p.active = false;
}
}
},
onRemove: function(map) {
for (var i = 0; i < this._providers.length; i++) {
var p = this._providers[i];
if (p.active && this._map.attributionControl) {
this._map.attributionControl.removeAttribution(p.attrib);
p.active = false;
}
}
L.TileLayer.prototype.onRemove.apply(this, [map]);
}
});
L.bingLayer = function (key, options) {
return new L.BingLayer(key, options);
};

202
external/Google.js vendored Normal file
View File

@ -0,0 +1,202 @@
/*
* Google layer using Google Maps API
*/
//(function (google, L) {
L.Google = L.Class.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.limitExecByInterval(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";
}
if (true) {
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)

14
external/Yandex.js vendored
View File

@ -95,15 +95,19 @@ L.Yandex = L.Class.extend({
// Check that ymaps.Map is ready
if (ymaps.Map === undefined) {
console.debug("L.Yandex: Waiting on ymaps.load('package.map')");
if (console) {
console.debug("L.Yandex: Waiting on ymaps.load('package.map')");
}
return ymaps.load(["package.map"], this._initMapObject, this);
}
// If traffic layer is requested check if control.TrafficControl is ready
if (this.options.traffic)
if (ymaps.control === undefined ||
ymaps.control.TrafficControl === undefined) {
console.debug("L.Yandex: loading traffic and controls");
ymaps.control.TrafficControl === undefined) {
if (console) {
console.debug("L.Yandex: loading traffic and controls");
}
return ymaps.load(["package.traffic", "package.controls"],
this._initMapObject, this);
}
@ -117,7 +121,7 @@ L.Yandex = L.Class.extend({
this._type = new ymaps.MapType("null", []);
map.container.getElement().style.background = "transparent";
}
map.setType(this._type)
map.setType(this._type);
this._yandex = map;
this._update(true);
@ -147,7 +151,7 @@ L.Yandex = L.Class.extend({
_resize: function(force) {
var size = this._map.getSize(), style = this._container.style;
if (style.width == size.x + "px" &&
style.height == size.y + "px")
style.height == size.y + "px")
if (force != true) return;
this.setElementSize(this._container, size);
var b = this._map.getBounds(), sw = b.getSouthWest(), ne = b.getNorthEast();

View File

@ -7,7 +7,7 @@
var oldL = window.L,
L = {};
L.version = '0.7-dev';
L.version = '0.7';
// define Leaflet for Node module pattern loaders, including Browserify
if (typeof module === 'object' && typeof module.exports === 'object') {
@ -961,18 +961,44 @@ L.DomUtil = {
},
hasClass: function (el, name) {
return (el.className.length > 0) &&
new RegExp('(^|\\s)' + name + '(\\s|$)').test(el.className);
if (el.classList !== undefined) {
return el.classList.contains(name);
}
var className = L.DomUtil._getClass(el);
return className.length > 0 && new RegExp('(^|\\s)' + name + '(\\s|$)').test(className);
},
addClass: function (el, name) {
if (!L.DomUtil.hasClass(el, name)) {
el.className += (el.className ? ' ' : '') + name;
if (el.classList !== undefined) {
var classes = L.Util.splitWords(name);
for (var i = 0, len = classes.length; i < len; i++) {
el.classList.add(classes[i]);
}
} else if (!L.DomUtil.hasClass(el, name)) {
var className = L.DomUtil._getClass(el);
L.DomUtil._setClass(el, (className ? className + ' ' : '') + name);
}
},
removeClass: function (el, name) {
el.className = L.Util.trim((' ' + el.className + ' ').replace(' ' + name + ' ', ' '));
if (el.classList !== undefined) {
el.classList.remove(name);
} else {
L.DomUtil._setClass(el, L.Util.trim((' ' + L.DomUtil._getClass(el) + ' ').replace(' ' + name + ' ', ' ')));
}
},
_setClass: function (el, name) {
if (el.className.baseVal === undefined) {
el.className = name;
} else {
// in case of SVG element
el.className.baseVal = name;
}
},
_getClass: function (el) {
return el.className.baseVal === undefined ? el.className : el.className.baseVal;
},
setOpacity: function (el, value) {
@ -1637,7 +1663,7 @@ L.Map = L.Class.extend({
},
panBy: function (offset) { // (Point)
// replaced with animated panBy in Map.Animation.js
// replaced with animated panBy in Map.PanAnimation.js
this.fire('movestart');
this._rawPanBy(L.point(offset));
@ -1646,63 +1672,29 @@ L.Map = L.Class.extend({
return this.fire('moveend');
},
setMaxBounds: function (bounds, options) {
setMaxBounds: function (bounds) {
bounds = L.latLngBounds(bounds);
this.options.maxBounds = bounds;
if (!bounds) {
this._boundsMinZoom = null;
this.off('moveend', this._panInsideMaxBounds, this);
return this;
return this.off('moveend', this._panInsideMaxBounds, this);
}
var minZoom = this.getBoundsZoom(bounds, true);
this._boundsMinZoom = minZoom;
if (this._loaded) {
if (this._zoom < minZoom) {
this.setView(bounds.getCenter(), minZoom, options);
} else {
this.panInsideBounds(bounds);
}
this._panInsideMaxBounds();
}
this.on('moveend', this._panInsideMaxBounds, this);
return this;
return this.on('moveend', this._panInsideMaxBounds, this);
},
panInsideBounds: function (bounds) {
bounds = L.latLngBounds(bounds);
panInsideBounds: function (bounds, options) {
var center = this.getCenter(),
newCenter = this._limitCenter(center, this._zoom, bounds);
var viewBounds = this.getPixelBounds(),
viewSw = viewBounds.getBottomLeft(),
viewNe = viewBounds.getTopRight(),
sw = this.project(bounds.getSouthWest()),
ne = this.project(bounds.getNorthEast()),
dx = 0,
dy = 0;
if (center.equals(newCenter)) { return this; }
if (viewNe.y < ne.y) { // north
dy = Math.ceil(ne.y - viewNe.y);
}
if (viewNe.x > ne.x) { // east
dx = Math.floor(ne.x - viewNe.x);
}
if (viewSw.y > sw.y) { // south
dy = Math.floor(sw.y - viewSw.y);
}
if (viewSw.x < sw.x) { // west
dx = Math.ceil(sw.x - viewSw.x);
}
if (dx || dy) {
return this.panBy([dx, dy]);
}
return this;
return this.panTo(newCenter, options);
},
addLayer: function (layer) {
@ -1787,10 +1779,6 @@ L.Map = L.Class.extend({
this._sizeChanged = true;
this._initialCenter = null;
if (this.options.maxBounds) {
this.setMaxBounds(this.options.maxBounds);
}
if (!this._loaded) { return this; }
var newSize = this.getSize(),
@ -1810,9 +1798,12 @@ L.Map = L.Class.extend({
this.fire('move');
// make sure moveend is not fired too often on resize
clearTimeout(this._sizeTimer);
this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200);
if (options.debounceMoveend) {
clearTimeout(this._sizeTimer);
this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200);
} else {
this.fire('moveend');
}
}
return this.fire('resize', {
@ -1885,9 +1876,9 @@ L.Map = L.Class.extend({
},
getMinZoom: function () {
var z1 = this._layersMinZoom === undefined ? 0 : this._layersMinZoom,
z2 = this._boundsMinZoom === undefined ? 0 : this._boundsMinZoom;
return this.options.minZoom === undefined ? Math.max(z1, z2) : this.options.minZoom;
return this.options.minZoom === undefined ?
(this._layersMinZoom === undefined ? 0 : this._layersMinZoom) :
this.options.minZoom;
},
getMaxZoom: function () {
@ -2210,7 +2201,7 @@ L.Map = L.Class.extend({
_onResize: function () {
L.Util.cancelAnimFrame(this._resizeRequest);
this._resizeRequest = L.Util.requestAnimFrame(
this.invalidateSize, this, false, this._container);
function () { this.invalidateSize({debounceMoveend: true}); }, this, false, this._container);
},
_onMouseClick: function (e) {
@ -2312,6 +2303,46 @@ L.Map = L.Class.extend({
return this.latLngToLayerPoint(latlng).subtract(this._getCenterLayerPoint());
},
// adjust center for view to get inside bounds
_limitCenter: function (center, zoom, bounds) {
if (!bounds) { return center; }
var centerPoint = this.project(center, zoom),
viewHalf = this.getSize().divideBy(2),
viewBounds = new L.Bounds(centerPoint.subtract(viewHalf), centerPoint.add(viewHalf)),
offset = this._getBoundsOffset(viewBounds, bounds, zoom);
return this.unproject(centerPoint.add(offset), zoom);
},
// adjust offset for view to get inside bounds
_limitOffset: function (offset, bounds) {
if (!bounds) { return offset; }
var viewBounds = this.getPixelBounds(),
newBounds = new L.Bounds(viewBounds.min.add(offset), viewBounds.max.add(offset));
return offset.add(this._getBoundsOffset(newBounds, bounds));
},
// returns offset needed for pxBounds to get inside maxBounds at a specified zoom
_getBoundsOffset: function (pxBounds, maxBounds, zoom) {
var nwOffset = this.project(maxBounds.getNorthWest(), zoom).subtract(pxBounds.min),
seOffset = this.project(maxBounds.getSouthEast(), zoom).subtract(pxBounds.max),
dx = this._rebound(nwOffset.x, -seOffset.x),
dy = this._rebound(nwOffset.y, -seOffset.y);
return new L.Point(dx, dy);
},
_rebound: function (left, right) {
return left + right > 0 ?
Math.round(left - right) / 2 :
Math.max(0, Math.ceil(left)) - Math.max(0, Math.floor(right));
},
_limitZoom: function (zoom) {
var min = this.getMinZoom(),
max = this.getMaxZoom();
@ -2669,7 +2700,7 @@ L.TileLayer = L.Class.extend({
_getTileSize: function () {
var map = this._map,
zoom = map.getZoom(),
zoom = map.getZoom() + this.options.zoomOffset,
zoomN = this.options.maxNativeZoom,
tileSize = this.options.tileSize;
@ -2875,7 +2906,7 @@ L.TileLayer = L.Class.extend({
_getWrapTileNum: function () {
var crs = this._map.options.crs,
size = crs.getSize(this._getZoomForUrl());
size = crs.getSize(this._map.getZoom());
return size.divideBy(this.options.tileSize);
},
@ -2922,6 +2953,11 @@ L.TileLayer = L.Class.extend({
if (L.Browser.ielt9 && this.options.opacity !== undefined) {
L.DomUtil.setOpacity(tile, this.options.opacity);
}
// without this hack, tiles disappear after zoom on Chrome for Android
// https://github.com/Leaflet/Leaflet/issues/2078
if (L.Browser.mobileWebkit3d) {
tile.style.WebkitBackfaceVisibility = 'hidden';
}
return tile;
},
@ -4413,6 +4449,15 @@ L.FeatureGroup = L.LayerGroup.extend({
return this.invoke('bindPopup', content, options);
},
openPopup: function (latlng) {
// open popup on the first layer
for (var id in this._layers) {
this._layers[id].openPopup(latlng);
break;
}
return this;
},
setStyle: function (style) {
return this.invoke('setStyle', style);
},
@ -4622,6 +4667,11 @@ L.Path = L.Path.extend({
this._container = this._createElement('g');
this._path = this._createElement('path');
if (this.options.className) {
L.DomUtil.addClass(this._path, this.options.className);
}
this._container.appendChild(this._path);
},
@ -4682,7 +4732,7 @@ L.Path = L.Path.extend({
_initEvents: function () {
if (this.options.clickable) {
if (L.Browser.svg || !L.Browser.vml) {
this._path.setAttribute('class', 'leaflet-clickable');
L.DomUtil.addClass(this._path, 'leaflet-clickable');
}
L.DomEvent.on(this._container, 'click', this._onMouseClick, this);
@ -4732,14 +4782,14 @@ L.Map.include({
this._panes.overlayPane.appendChild(this._pathRoot);
if (this.options.zoomAnimation && L.Browser.any3d) {
this._pathRoot.setAttribute('class', ' leaflet-zoom-animated');
L.DomUtil.addClass(this._pathRoot, 'leaflet-zoom-animated');
this.on({
'zoomanim': this._animatePathZoom,
'zoomend': this._endPathZoom
});
} else {
this._pathRoot.setAttribute('class', ' leaflet-zoom-hide');
L.DomUtil.addClass(this._pathRoot, 'leaflet-zoom-hide');
}
this.on('moveend', this._updateSvgViewport);
@ -4906,10 +4956,14 @@ L.Path = L.Browser.svg || !L.Browser.vml ? L.Path : L.Path.extend({
_initPath: function () {
var container = this._container = this._createElement('shape');
L.DomUtil.addClass(container, 'leaflet-vml-shape');
L.DomUtil.addClass(container, 'leaflet-vml-shape' +
(this.options.className ? ' ' + this.options.className : ''));
if (this.options.clickable) {
L.DomUtil.addClass(container, 'leaflet-clickable');
}
container.coordsize = '1 1';
this._path = this._createElement('path');
@ -6685,9 +6739,8 @@ L.Draggable = L.Class.extend({
this._moved = true;
this._startPos = L.DomUtil.getPosition(this._element).subtract(offset);
if (!L.Browser.touch) {
L.DomUtil.addClass(document.body, 'leaflet-dragging');
}
L.DomUtil.addClass(document.body, 'leaflet-dragging');
L.DomUtil.addClass((e.target || e.srcElement), 'leaflet-drag-target');
}
this._newPos = this._startPos.add(offset);
@ -6703,10 +6756,9 @@ L.Draggable = L.Class.extend({
this.fire('drag');
},
_onUp: function () {
if (!L.Browser.touch) {
L.DomUtil.removeClass(document.body, 'leaflet-dragging');
}
_onUp: function (e) {
L.DomUtil.removeClass(document.body, 'leaflet-dragging');
L.DomUtil.removeClass((e.target || e.srcElement), 'leaflet-drag-target');
for (var i in L.Draggable.MOVE) {
L.DomEvent
@ -6898,6 +6950,8 @@ L.Map.Drag = L.Handler.extend({
map.fire('moveend');
} else {
offset = map._limitOffset(offset, map.options.maxBounds);
L.Util.requestAnimFrame(function () {
map.panBy(offset, {
duration: decelerationDuration,
@ -6932,7 +6986,7 @@ L.Map.DoubleClickZoom = L.Handler.extend({
_onDoubleClick: function (e) {
var map = this._map,
zoom = map.getZoom() + 1;
zoom = map.getZoom() + (e.originalEvent.shiftKey ? -1 : 1);
if (map.options.doubleClickZoom === 'center') {
map.setZoom(zoom);
@ -7550,21 +7604,22 @@ L.Map.BoxZoom = L.Handler.extend({
this._startLayerPoint = this._map.mouseEventToLayerPoint(e);
this._box = L.DomUtil.create('div', 'leaflet-zoom-box', this._pane);
L.DomUtil.setPosition(this._box, this._startLayerPoint);
//TODO refactor: move cursor to styles
this._container.style.cursor = 'crosshair';
L.DomEvent
.on(document, 'mousemove', this._onMouseMove, this)
.on(document, 'mouseup', this._onMouseUp, this)
.on(document, 'keydown', this._onKeyDown, this);
this._map.fire('boxzoomstart');
},
_onMouseMove: function (e) {
if (!this._moved) {
this._box = L.DomUtil.create('div', 'leaflet-zoom-box', this._pane);
L.DomUtil.setPosition(this._box, this._startLayerPoint);
//TODO refactor: move cursor to styles
this._container.style.cursor = 'crosshair';
this._map.fire('boxzoomstart');
}
var startPoint = this._startLayerPoint,
box = this._box,
@ -7585,8 +7640,10 @@ L.Map.BoxZoom = L.Handler.extend({
},
_finish: function () {
this._pane.removeChild(this._box);
this._container.style.cursor = '';
if (this._moved) {
this._pane.removeChild(this._box);
this._container.style.cursor = '';
}
L.DomUtil.enableTextSelection();
L.DomUtil.enableImageDrag();
@ -7821,7 +7878,6 @@ L.Handler.MarkerDrag = L.Handler.extend({
.closePopup()
.fire('movestart')
.fire('dragstart');
L.DomUtil.addClass(this._marker._icon, 'leaflet-marker-dragging');
},
_onDrag: function () {
@ -7846,7 +7902,6 @@ L.Handler.MarkerDrag = L.Handler.extend({
this._marker
.fire('moveend')
.fire('dragend', e);
L.DomUtil.removeClass(this._marker._icon, 'leaflet-marker-dragging');
}
});
@ -8086,6 +8141,12 @@ L.Control.Attribution = L.Control.extend({
this._container = L.DomUtil.create('div', 'leaflet-control-attribution');
L.DomEvent.disableClickPropagation(this._container);
for (var i in map._layers) {
if (map._layers[i].getAttribution) {
this.addAttribution(map._layers[i].getAttribution());
}
}
map
.on('layeradd', this._onLayerAdd, this)
.on('layerremove', this._onLayerRemove, this);
@ -8656,7 +8717,7 @@ L.Map.include({
setView: function (center, zoom, options) {
zoom = zoom === undefined ? this._zoom : this._limitZoom(zoom);
center = L.latLng(center);
center = this._limitCenter(L.latLng(center), zoom, this.options.maxBounds);
options = options || {};
if (this._panAnim) {

82
external/leaflet.css vendored
View File

@ -42,10 +42,6 @@
.leaflet-container img.leaflet-image-layer {
max-width: 15000px !important;
}
/* Android chrome makes tiles disappear without this */
.leaflet-tile-container img {
-webkit-backface-visibility: hidden;
}
.leaflet-tile {
filter: inherit;
visibility: hidden;
@ -174,9 +170,8 @@
.leaflet-control {
cursor: auto;
}
.leaflet-dragging,
.leaflet-dragging .leaflet-clickable,
.leaflet-dragging .leaflet-container {
.leaflet-dragging .leaflet-container,
.leaflet-dragging .leaflet-clickable {
cursor: move;
cursor: -webkit-grabbing;
cursor: -moz-grabbing;
@ -210,9 +205,8 @@
/* general toolbar styles */
.leaflet-bar {
box-shadow: 0 1px 7px rgba(0,0,0,0.65);
-webkit-border-radius: 4px;
border-radius: 4px;
box-shadow: 0 1px 5px rgba(0,0,0,0.65);
border-radius: 4px;
}
.leaflet-bar a,
.leaflet-bar a:hover {
@ -236,16 +230,12 @@
background-color: #f4f4f4;
}
.leaflet-bar a:first-child {
-webkit-border-top-left-radius: 4px;
border-top-left-radius: 4px;
-webkit-border-top-right-radius: 4px;
border-top-right-radius: 4px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.leaflet-bar a:last-child {
-webkit-border-bottom-left-radius: 4px;
border-bottom-left-radius: 4px;
-webkit-border-bottom-right-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom: none;
}
.leaflet-bar a.leaflet-disabled {
@ -254,55 +244,38 @@
color: #bbb;
}
.leaflet-touch .leaflet-bar {
-webkit-border-radius: 10px;
border-radius: 10px;
}
.leaflet-touch .leaflet-bar a {
width: 30px;
height: 30px;
}
.leaflet-touch .leaflet-bar a:first-child {
-webkit-border-top-left-radius: 7px;
border-top-left-radius: 7px;
-webkit-border-top-right-radius: 7px;
border-top-right-radius: 7px;
}
.leaflet-touch .leaflet-bar a:last-child {
-webkit-border-bottom-left-radius: 7px;
border-bottom-left-radius: 7px;
-webkit-border-bottom-right-radius: 7px;
border-bottom-right-radius: 7px;
border-bottom: none;
line-height: 30px;
}
/* zoom control */
.leaflet-control-zoom-in {
.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
font: bold 18px 'Lucida Console', Monaco, monospace;
text-indent: 1px;
}
.leaflet-control-zoom-out {
font: bold 22px 'Lucida Console', Monaco, monospace;
font-size: 20px;
}
.leaflet-touch .leaflet-control-zoom-in {
font-size: 22px;
line-height: 30px;
}
.leaflet-touch .leaflet-control-zoom-out {
font-size: 28px;
line-height: 30px;
font-size: 24px;
}
/* layers control */
.leaflet-control-layers {
box-shadow: 0 1px 7px rgba(0,0,0,0.4);
box-shadow: 0 1px 5px rgba(0,0,0,0.4);
background: #fff;
-webkit-border-radius: 5px;
border-radius: 5px;
border-radius: 5px;
}
.leaflet-control-layers-toggle {
background-image: url(@@INCLUDEIMAGE:images/layers.png@@);
@ -310,7 +283,7 @@
height: 36px;
}
.leaflet-retina .leaflet-control-layers-toggle {
background-image: url(@@INCLUDEIMATE:images/layers-2x.png@@);
background-image: url(@@INCLUDEIMAGE:images/layers-2x.png@@);
background-size: 26px 26px;
}
.leaflet-touch .leaflet-control-layers-toggle {
@ -350,7 +323,6 @@
.leaflet-container .leaflet-control-attribution {
background: #fff;
background: rgba(255, 255, 255, 0.7);
box-shadow: 0 0 5px #bbb;
margin: 0;
}
.leaflet-control-attribution,
@ -358,6 +330,12 @@
padding: 0 5px;
color: #333;
}
.leaflet-control-attribution a {
text-decoration: none;
}
.leaflet-control-attribution a:hover {
text-decoration: underline;
}
.leaflet-container .leaflet-control-attribution,
.leaflet-container .leaflet-control-scale {
font-size: 11px;
@ -379,17 +357,13 @@
-moz-box-sizing: content-box;
box-sizing: content-box;
color: black;
background: #fff;
background: rgba(255, 255, 255, 0.5);
box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.2);
text-shadow: 1px 1px 1px #fff;
}
.leaflet-control-scale-line:not(:first-child) {
border-top: 2px solid #777;
border-bottom: none;
margin-top: -2px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.leaflet-control-scale-line:not(:first-child):not(:last-child) {
border-bottom: 2px solid #777;
@ -402,7 +376,8 @@
}
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
border: 4px solid rgba(0,0,0,0.3);
border: 2px solid rgba(0,0,0,0.2);
background-clip: padding-box;
}
@ -415,8 +390,7 @@
.leaflet-popup-content-wrapper {
padding: 1px;
text-align: left;
-webkit-border-radius: 12px;
border-radius: 12px;
border-radius: 12px;
}
.leaflet-popup-content {
margin: 13px 19px;
@ -502,7 +476,3 @@
background: #fff;
border: 1px solid #666;
}
.leaflet-editing-icon {
-webkit-border-radius: 2px;
border-radius: 2px;
}

8
external/leaflet.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,158 +0,0 @@
/*
* L.TileLayer is used for standard xyz-numbered tile layers.
*/
L.Google = L.Class.extend({
includes: L.Mixin.Events,
options: {
minZoom: 0,
maxZoom: 18,
tileSize: 256,
subdomains: 'abc',
errorTileUrl: '',
attribution: '',
opacity: 1,
continuousWorld: false,
noWrap: false,
},
// Possible types: SATELLITE, ROADMAP, HYBRID, INGRESS
initialize: function(type, options, styles) {
L.Util.setOptions(this, options);
if(type === 'INGRESS') {
type = 'ROADMAP';
this._styles = [{featureType:"all", elementType:"all", stylers:[{visibility:"on"}, {hue:"#131c1c"}, {saturation:"-50"}, {invert_lightness:true}]}, {featureType:"water", elementType:"all", stylers:[{visibility:"on"}, {hue:"#005eff"}, {invert_lightness:true}]}, {featureType:"poi", stylers:[{visibility:"off"}]}, {featureType:"transit", elementType:"all", stylers:[{visibility:"off"}]}];
} else {
this._styles = null;
}
this._type = google.maps.MapTypeId[type || 'SATELLITE'];
},
onAdd: function(map, insertAtTheBottom) {
this._map = map;
this._insertAtTheBottom = insertAtTheBottom;
// create a container div for tiles
this._initContainer();
this._initMapObject();
this._map.options.zoomAnimation = false;
// set up events
//~ map.on('viewreset', this._resetCallback, this);
map.on('move', this._update, this);
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.options.zoomAnimation = true;
this._map.off('move', this._update, this);
//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);
}
},
_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";
}
if (true) {
tilePane.insertBefore(this._container, first);
this.setOpacity(this.options.opacity);
var size = this._map.getSize();
this._container.style.width = size.x + 'px';
this._container.style.height = size.y + 'px';
}
},
_initMapObject: function() {
this._google_center = new google.maps.LatLng(0, 0);
var map = new google.maps.Map(this._container, {
center: this._google_center,
zoom: 0,
styles: this._styles,
tilt: 0,
mapTypeId: this._type,
disableDefaultUI: true,
keyboardShortcuts: false,
draggable: false,
disableDoubleClickZoom: true,
scrollwheel: false,
streetViewControl: false
});
var _this = this;
this._reposition = google.maps.event.addListenerOnce(map, "center_changed",
function() { _this.onReposition(); });
map.backgroundColor = '#ff0000';
this._google = map;
this._lastZoomPosition = null;
this._lastMapPosition = null;
},
_resetCallback: function(e) {
this._reset(e.hard);
},
_reset: function(clearOldContainer) {
this._initContainer();
},
_update: function() {
this._resize();
// update map position if required
var newCenter = this._map.getCenter();
if(this._lastMapPosition !== newCenter) {
var _center = new google.maps.LatLng(newCenter.lat, newCenter.lng);
this._google.setCenter(_center);
}
this._lastMapPosition = newCenter;
// update zoom level if required
var newZoom = this._map.getZoom();
if(this._lastZoomPosition !== newZoom) {
this._google.setZoom(this._map.getZoom());
}
this._lastZoomPosition = newZoom;
},
_resize: function() {
var size = this._map.getSize();
if (parseInt(this._container.style.width) == size.x &&
parseInt(this._container.style.height) == size.y)
return;
this._container.style.width = size.x + 'px';
this._container.style.height = size.y + 'px';
google.maps.event.trigger(this._google, "resize");
},
onReposition: function() {
//google.maps.event.trigger(this._google, "resize");
}
});

View File

@ -1,9 +1,8 @@
// ==UserScript==
// ==UserScript==
// @id iitc-plugin-bing-maps
// @name IITC plugin: Bing maps
// @category Map Tiles
// @version 0.1.0.@@DATETIMEVERSION@@
// @version 0.1.1.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
@ -22,127 +21,7 @@
window.plugin.mapBing = function() {};
window.plugin.mapBing.setupBingLeaflet = function() {
//---------------------------------------------------------------------
// https://github.com/shramov/leaflet-plugins/blob/master/layer/tile/Bing.js
L.BingLayer = L.TileLayer.extend({
options: {
subdomains: [0, 1, 2, 3],
type: 'Aerial',
attribution: 'Bing',
culture: ''
},
initialize: function(key, options) {
L.Util.setOptions(this, options);
this._key = key;
this._url = null;
this.meta = {};
this.loadMetadata();
},
tile2quad: function(x, y, z) {
var quad = '';
for (var i = z; i > 0; i--) {
var digit = 0;
var mask = 1 << (i - 1);
if ((x & mask) != 0) digit += 1;
if ((y & mask) != 0) digit += 2;
quad = quad + digit;
}
return quad;
},
getTileUrl: function(p, z) {
var z = this._getZoomForUrl();
var subdomains = this.options.subdomains,
s = this.options.subdomains[Math.abs((p.x + p.y) % subdomains.length)];
return this._url.replace('{subdomain}', s)
.replace('{quadkey}', this.tile2quad(p.x, p.y, z))
.replace('{culture}', this.options.culture);
},
loadMetadata: function() {
// TODO? modify this to cache the metadata in - say - sessionStorage? localStorage?
var _this = this;
var cbid = '_bing_metadata_' + L.Util.stamp(this);
window[cbid] = function (meta) {
_this.meta = meta;
window[cbid] = undefined;
var e = document.getElementById(cbid);
e.parentNode.removeChild(e);
if (meta.errorDetails) {
alert("Got metadata" + meta.errorDetails);
return;
}
_this.initMetadata();
};
var url = "//dev.virtualearth.net/REST/v1/Imagery/Metadata/" + this.options.type + "?include=ImageryProviders&jsonp=" + cbid + "&key=" + this._key;
var script = document.createElement("script");
script.type = "text/javascript";
script.src = url;
script.id = cbid;
document.getElementsByTagName("head")[0].appendChild(script);
},
initMetadata: function() {
var r = this.meta.resourceSets[0].resources[0];
this.options.subdomains = r.imageUrlSubdomains;
this._url = r.imageUrl;
this._providers = [];
for (var i = 0; i < r.imageryProviders.length; i++) {
var p = r.imageryProviders[i];
for (var j = 0; j < p.coverageAreas.length; j++) {
var c = p.coverageAreas[j];
var coverage = {zoomMin: c.zoomMin, zoomMax: c.zoomMax, active: false};
var bounds = new L.LatLngBounds(
new L.LatLng(c.bbox[0]+0.01, c.bbox[1]+0.01),
new L.LatLng(c.bbox[2]-0.01, c.bbox[3]-0.01)
);
coverage.bounds = bounds;
coverage.attrib = p.attribution;
this._providers.push(coverage);
}
}
this._update();
},
_update: function() {
if (this._url == null || !this._map) return;
this._update_attribution();
L.TileLayer.prototype._update.apply(this, []);
},
_update_attribution: function() {
var bounds = this._map.getBounds();
var zoom = this._map.getZoom();
for (var i = 0; i < this._providers.length; i++) {
var p = this._providers[i];
if ((zoom <= p.zoomMax && zoom >= p.zoomMin) &&
bounds.intersects(p.bounds)) {
if (!p.active)
this._map.attributionControl.addAttribution(p.attrib);
p.active = true;
} else {
if (p.active)
this._map.attributionControl.removeAttribution(p.attrib);
p.active = false;
}
}
},
onRemove: function(map) {
for (var i = 0; i < this._providers.length; i++) {
var p = this._providers[i];
if (p.active) {
this._map.attributionControl.removeAttribution(p.attrib);
p.active = false;
}
}
L.TileLayer.prototype.onRemove.apply(this, [map]);
}
});
//---------------------------------------------------------------------
@@INCLUDERAW:external/Bing.js@@
}

View File

@ -2,7 +2,7 @@
// @id iitc-plugin-basemap-gmaps-gray@jacob1123
// @name IITC plugin: Gray Google Roads
// @category Map Tiles
// @version 0.1.0.@@DATETIMEVERSION@@
// @version 0.1.1.@@DATETIMEVERSION@@
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
// @updateURL @@UPDATEURL@@
// @downloadURL @@DOWNLOADURL@@
@ -21,10 +21,25 @@
// use own namespace for plugin
window.plugin.grayGMaps = function() {};
window.plugin.grayGMaps.addLayer = function() {
var grayGMaps = new L.Google('ROADMAPS',{maxZoom:20});
grayGMaps._styles = [{featureType:"landscape.natural",stylers:[{visibility:"simplified"},{saturation:-100},{lightness:-80},{gamma:2.44}]},{featureType:"road",stylers:[{visibility:"simplified"},{color:"#bebebe"},{weight:.6}]},{featureType:"poi",stylers:[{saturation:-100},{visibility:"on"},{gamma:.14}]},{featureType:"water",stylers:[{color:"#32324f"}]},{featureType:"transit",stylers:[{visibility:"off"}]},{featureType:"road",elementType:"labels",stylers:[{visibility:"off"}]},{featureType:"poi",elementType:"labels",stylers:[{visibility:"off"}]},{featureType:"poi"},{featureType:"landscape.man_made",stylers:[{saturation:-100},{gamma:.13}]},{featureType:"water",elementType:"labels",stylers:[{visibility:"off"}]}]
var grayGMapsOptions = {
backgroundColor: '#0e3d4e', //or #dddddd ? - that's the Google tile layer default
styles: [
{featureType:"landscape.natural",stylers:[{visibility:"simplified"},{saturation:-100},{lightness:-80},{gamma:2.44}]},
{featureType:"road",stylers:[{visibility:"simplified"},{color:"#bebebe"},{weight:.6}]},
{featureType:"poi",stylers:[{saturation:-100},{visibility:"on"},{gamma:.14}]},
{featureType:"water",stylers:[{color:"#32324f"}]},
{featureType:"transit",stylers:[{visibility:"off"}]},
{featureType:"road",elementType:"labels",stylers:[{visibility:"off"}]},
{featureType:"poi",elementType:"labels",stylers:[{visibility:"off"}]},
{featureType:"poi"},
{featureType:"landscape.man_made",stylers:[{saturation:-100},{gamma:.13}]},
{featureType:"water",elementType:"labels",stylers:[{visibility:"off"}]}
]
};
layerChooser.addBaseLayer(grayGMaps, "Google Gray");
var grayGMaps = new L.Google('ROA#DMAP',{maxZoom:20, mapOptions: grayGMapsOptions});
layerChooser.addBaseLayer(grayGMaps, "Google Gray");
};
var setup = window.plugin.grayGMaps.addLayer;