1/* 2 * L.TileLayer is used for standard xyz-numbered tile layers. 3 */ 4 5L.Google = L.Class.extend({ 6 includes: L.Mixin.Events, 7 options: { 8 minZoom: 0, 9 maxZoom: 18, 10 tileSize: 256, 11 subdomains: 'abc', 12 errorTileUrl: '', 13 attribution: '', 14 opacity: 1, 15 continuousWorld: false, 16 noWrap: false, 17 styles:'', 18 }, 19 20 // Possible types: SATELLITE, ROADMAP, HYBRID 21 initialize: function(type, options) { 22 L.Util.setOptions(this, options); 23 24 this._type = google.maps.MapTypeId[type || 'SATELLITE']; 25 }, 26 27 onAdd: function(map, insertAtTheBottom) { 28 this._map = map; 29 this._insertAtTheBottom = insertAtTheBottom; 30 31 // create a container div for tiles 32 this._initContainer(); 33 this._initMapObject(); 34 35 // set up events 36 map.on('viewreset', this._resetCallback, this); 37 38 this._limitedUpdate = L.Util.limitExecByInterval(this._update, 150, this); 39 map.on('move', this._update, this); 40 //map.on('moveend', this._update, this); 41 42 this._reset(); 43 this._update(); 44 }, 45 46 onRemove: function(map) { 47 this._map._container.removeChild(this._container); 48 //this._container = null; 49 50 this._map.off('viewreset', this._resetCallback, this); 51 52 this._map.off('move', this._update, this); 53 //this._map.off('moveend', this._update, this); 54 }, 55 56 getAttribution: function() { 57 return this.options.attribution; 58 }, 59 60 setOpacity: function(opacity) { 61 this.options.opacity = opacity; 62 if (opacity < 1) { 63 L.DomUtil.setOpacity(this._container, opacity); 64 } 65 }, 66 67 _initContainer: function() { 68 var tilePane = this._map._container 69 first = tilePane.firstChild; 70 71 if (!this._container) { 72 this._container = L.DomUtil.create('div', 'leaflet-google-layer leaflet-top leaflet-left'); 73 this._container.id = "_GMapContainer"; 74 } 75 76 if (true) { 77 tilePane.insertBefore(this._container, first); 78 79 this.setOpacity(this.options.opacity); 80 var size = this._map.getSize(); 81 this._container.style.width = size.x + 'px'; 82 this._container.style.height = size.y + 'px'; 83 } 84 }, 85 86 _initMapObject: function() { 87 this._google_center = new google.maps.LatLng(0, 0); 88 var map = new google.maps.Map(this._container, { 89 center: this._google_center, 90 zoom: 0, 91 mapTypeId: this._type, 92 disableDefaultUI: true, 93 keyboardShortcuts: false, 94 draggable: false, 95 disableDoubleClickZoom: true, 96 scrollwheel: false, 97 streetViewControl: false, 98 styles: this.options.styles 99 }); 100 101 var _this = this; 102 this._reposition = google.maps.event.addListenerOnce(map, "center_changed", 103 function() { _this.onReposition(); }); 104 105 map.backgroundColor = '#ff0000'; 106 this._google = map; 107 }, 108 109 _resetCallback: function(e) { 110 this._reset(e.hard); 111 }, 112 113 _reset: function(clearOldContainer) { 114 this._initContainer(); 115 }, 116 117 _update: function() { 118 this._resize(); 119 120 var bounds = this._map.getBounds(); 121 var ne = bounds.getNorthEast();
122 var sw = bounds.getSouthWest(); 123 var google_bounds = new google.maps.LatLngBounds( 124 new google.maps.LatLng(sw.lat, sw.lng), 125 new google.maps.LatLng(ne.lat, ne.lng) 126 ); 127 var center = this._map.getCenter(); 128 var _center = new google.maps.LatLng(center.lat, center.lng); 129 130 this._google.setCenter(_center); 131 this._google.setZoom(this._map.getZoom()); 132 //this._google.fitBounds(google_bounds); 133 }, 134 135 _resize: function() { 136 var size = this._map.getSize(); 137 if (this._container.style.width == size.x && 138 this._container.style.height == size.y) 139 return; 140 this._container.style.width = size.x + 'px'; 141 this._container.style.height = size.y + 'px'; 142 google.maps.event.trigger(this._google, "resize"); 143 }, 144 145 onReposition: function() { 146 //google.maps.event.trigger(this._google, "resize"); 147 } 148});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.