From fc5b82481cdb253a27c4a96c65224fa6d8437cc2 Mon Sep 17 00:00:00 2001 From: lrullo Date: Mon, 12 Nov 2018 17:13:32 +0100 Subject: [PATCH] =?UTF-8?q?Uso=20de=20mapas=20de=20mapbox=20para=20la=20cr?= =?UTF-8?q?eaci=C3=B3n=20de=20markers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/soundmap.add.js | 25 +++++++++++++++++-------- js/soundmap.config.js | 16 +++++++++++++++- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/js/soundmap.add.js b/js/soundmap.add.js index 34c10f1..6415713 100644 --- a/js/soundmap.add.js +++ b/js/soundmap.add.js @@ -21,15 +21,24 @@ initMap: function(){ - this.map = L.map('map_canvas',{center: [this.origin.lat, this.origin.lng], zoom: this.origin.zoom}); - this.layers.push(new L.Google()); - this.layers.push(new L.Google('TERRAIN')); - this.map.addLayer(this.layers[0]); + //this.layers.push(new L.Google()); + //this.layers.push(new L.Google('TERRAIN')); + //this.map.addLayer(this.layers[0]); + /* L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={pk.eyJ1IjoibHJ1bGxvIiwiYSI6ImNpaDUydjdoNTAwd3BzdGx5bGlhOTh6bXYifQ.tE8QgNbVSgwP8V5LnJWA3w}', { + attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox', + maxZoom: 18, + id: 'mapbox.streets', + accessToken: 'your.mapbox.access.token' + }).addTo(this.map);*/ + mapboxUrl = 'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibHJ1bGxvIiwiYSI6ImNpaDUydjdoNTAwd3BzdGx5bGlhOTh6bXYifQ.tE8QgNbVSgwP8V5LnJWA3w'; + var grayscale = L.tileLayer(mapboxUrl, {id: 'mapbox.light'}), + streets = L.tileLayer(mapboxUrl, {id: 'mapbox.streets'}); + this.map = L.map('map_canvas',{center: [this.origin.lat, this.origin.lng], zoom: this.origin.zoom, layers: [grayscale,streets]}); this.map.addControl( new L.Control.Layers( { - 'Google':this.layers[0], - 'Google Terrain': this.layers[1] + 'Grayscale':grayscale, + 'Streets': streets }, {} ) ); @@ -42,7 +51,7 @@ this.map.panTo(_latlng); this.marker.addEventListener('dragend', this.markerDrag, this); } - _.bindAll(this); + //_.bindAll(this); this.initEvents(); ; @@ -106,4 +115,4 @@ soundmap.initMap(); }); -}(jQuery)); \ No newline at end of file +}(jQuery)); diff --git a/js/soundmap.config.js b/js/soundmap.config.js index 6e1b280..9568966 100644 --- a/js/soundmap.config.js +++ b/js/soundmap.config.js @@ -8,6 +8,7 @@ layers:{}, initMap: function(){ + /* this.map = L.map('map_canvas_options',{center: [this.origin.lat, this.origin.lng], zoom: this.origin.zoom}); this.layers.SATELLITE = new L.Google(); this.layers.TERRAIN = new L.Google('TERRAIN'); @@ -23,8 +24,21 @@ 'Google Roadmap': this.layers.ROADMAP }, {} ) + );*/ + mapboxUrl = 'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibHJ1bGxvIiwiYSI6ImNpaDUydjdoNTAwd3BzdGx5bGlhOTh6bXYifQ.tE8QgNbVSgwP8V5LnJWA3w'; + var grayscale = L.tileLayer(mapboxUrl, {id: 'mapbox.light'}), + streets = L.tileLayer(mapboxUrl, {id: 'mapbox.streets'}); + this.map = L.map('map_canvas_options',{center: [this.origin.lat, this.origin.lng], zoom: this.origin.zoom, layers: [grayscale,streets]}); + this.map.addControl( + new L.Control.Layers( + { + 'Grayscale':grayscale, + 'Streets': streets + }, {} + ) ); + this.map.addEventListener('dragend', this.mapDrag, this); this.map.addEventListener('zoomend', this.mapZoom, this); this.map.addEventListener('baselayerchange', this.layerChange, this); @@ -60,4 +74,4 @@ soundmap.initMap(); }); -}(jQuery)); \ No newline at end of file +}(jQuery));