diff --git a/css/soundmap.front.css b/css/soundmap.front.css index e69de29..68c6236 100644 --- a/css/soundmap.front.css +++ b/css/soundmap.front.css @@ -0,0 +1 @@ +div.soinumapa-map{ width:100%;height:50vh;} diff --git a/js/soundmap.front.js b/js/soundmap.front.js index e614056..323899f 100644 --- a/js/soundmap.front.js +++ b/js/soundmap.front.js @@ -14,27 +14,20 @@ }, init: function (selector, query){ - console.log(selector+'.... '+query); - //this.map = L.map(selector,{center: [this.origin.lat, this.origin.lng], zoom: this.origin.zoom, scrollWheelZoom: false}); - L.mapbox.accessToken = 'pk.eyJ1IjoibHJ1bGxvIiwiYSI6ImNpaDUydjdoNTAwd3BzdGx5bGlhOTh6bXYifQ.tE8QgNbVSgwP8V5LnJWA3w'; - this.map = L.mapbox.map(selector,'lrullo.cih52v78z00v4krkrzge97rgg',{center: [this.origin.lat, this.origin.lng], zoom: this.origin.zoom, scrollWheelZoom: false}); - /*this.layers.SATELLITE = new L.Google(); - this.layers.TERRAIN = new L.Google('TERRAIN'); - this.layers.HYBRID = new L.Google('HYBRID'); - this.layers.ROADMAP = new L.Google('ROADMAP');*/ - //this.layers.MAPBOX - //this.map.addLayer(this.layers[this.mapType]); - /*this.map.addControl( - new L.Control.Layers( - { - 'Google':this.layers.SATELLITE, - 'Google Terrain': this.layers.TERRAIN, - 'Google Hybrid': this.layers.HYBRID, - 'Google Roadmap': this.layers.ROADMAP - }, {} - ) - );*/ - //_.bindAll(this); + mapboxUrl = 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibHJ1bGxvIiwiYSI6ImNpaDUydjdoNTAwd3BzdGx5bGlhOTh6bXYifQ.tE8QgNbVSgwP8V5LnJWA3w'; + var grayscale = L.tileLayer(mapboxUrl, {id: 'mapbox/light-v10'}), + streets = L.tileLayer(mapboxUrl, {id: 'mapbox/streets-v11'}), + osm = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'); + this.map = L.map(selector,{center: [this.origin.lat, this.origin.lng], zoom: this.origin.zoom, layers: [osm,grayscale,streets]}); + this.map.addControl( + new L.Control.Layers( + { + 'OSM': osm, + 'Grayscale':grayscale, + 'Streets': streets + }, {} + ) + ); options = { type: 'POST', @@ -46,10 +39,8 @@ } }; - console.log(options); // Use with PHP's wp_send_json_success() and wp_send_json_error() $.ajax( options ).done(this.ajaxDone).fail(this.ajaxFail); - console.log(this.infos); }, addMapCallback: function (event, callback){ @@ -57,7 +48,7 @@ }, onMarkerClick: function(event){ - self = window.Soundmap; + self = window.Soundmap; var id = event.target.feature.properties.id; self.ajaxMarker = event.target; if(self.infos[id]){ @@ -100,13 +91,14 @@ }, ajaxDone: function(response){ - console.log('done'+response); var self = this; this.markers = L.geoJson(response.data,{ onEachFeature: function(feature, layer){ layer.on('click', self.onMarkerClick); } }).addTo(this.map); + this.map.fitBounds(this.markers.getBounds()); + }, ajaxFail: function(){ console.log(this); @@ -116,8 +108,9 @@ $(document).ready(function(){ //soundmap.initMap(); - soundmap.init('map-content',''); - console.log('document.ready'); + if ($('#map_canvas').length) { + soundmap.init('map_canvas',''); + } }); diff --git a/soundmap.php b/soundmap.php index 0259871..f6b5f21 100644 --- a/soundmap.php +++ b/soundmap.php @@ -31,6 +31,15 @@ if (!class_exists('Soundmap')){ //Register hooks and filters $this->register_hooks(); $this->register_filters(); + $this->register_shortcode(); + } + + function register_shortcode() { + add_shortcode('soinumapa-map',array($this,'shortcode_map')); + } + + function shortcode_map($atts) { + return '
'; } function register_content_type(){ @@ -400,7 +409,7 @@ if (!class_exists('Soundmap')){ ) ); }); - + function marker_get_georeference ($object, $field_name, $request){ //return $object['id']; $lat = get_post_meta($object['id'], 'soundmap_marker_lat', true); @@ -416,7 +425,7 @@ if (!class_exists('Soundmap')){ $files = get_post_meta($object['id'], 'soundmap_attachments_id', FALSE); $files_str = []; if ($files) : - foreach($files as $file){ + foreach($files as $file){ $data = wp_prepare_attachment_for_js( $file ); array_push($files_str,$data); } @@ -429,7 +438,7 @@ if (!class_exists('Soundmap')){ add_action('wp_ajax_nopriv_soundmap_verify_captcha', array($this, 'verify_captcha'));*/ } - + function add_feed(){ global $wp_rewrite; diff --git a/theme/theme_window.php b/theme/theme_window.php index bcb2431..654fd74 100644 --- a/theme/theme_window.php +++ b/theme/theme_window.php @@ -10,7 +10,7 @@ autor) && $mark->autor){ ?>

autor; ?>


- +
'); ?>