Compare commits

...

2 Commits

Author SHA1 Message Date
0d18486fc7 Update: LeafletJS library to 1.9.3 2022-12-14 01:03:51 +01:00
eeefc257bf Add: Shortcut Map 2022-12-14 01:02:15 +01:00
4 changed files with 36 additions and 33 deletions

View File

@ -0,0 +1 @@
div.soinumapa-map{ width:100%;height:50vh;}

View File

@ -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(
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(
{
'Google':this.layers.SATELLITE,
'Google Terrain': this.layers.TERRAIN,
'Google Hybrid': this.layers.HYBRID,
'Google Roadmap': this.layers.ROADMAP
'OSM': osm,
'Grayscale':grayscale,
'Streets': streets
}, {}
)
);*/
//_.bindAll(this);
);
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){
@ -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','');
}
});

View File

@ -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 '<div id="map_canvas" class="soinumapa-map"></div>';
}
function register_content_type(){
@ -171,8 +180,8 @@ if (!class_exists('Soundmap')){
}// admin_menu
function enqueue_map_scripts(){
wp_enqueue_script('leafletjs','https://unpkg.com/leaflet@1.6.0/dist/leaflet.js',array(),'1.6.0',TRUE); // add Leaflet.js
wp_enqueue_style('leafletcss',"https://unpkg.com/leaflet@1.6.0/dist/leaflet.css",array(),'1.6.0','all'); // add CSS Leaflet
wp_enqueue_script('leafletjs','https://unpkg.com/leaflet@1.9.3/dist/leaflet.js',array(),'1.9.3',TRUE); // add Leaflet.js
wp_enqueue_style('leafletcss',"https://unpkg.com/leaflet@1.9.3/dist/leaflet.css",array(),'1.9.3','all'); // add CSS Leaflet
}
function wp_enqueue_scripts(){

View File

@ -10,7 +10,7 @@
<?php if(isset($mark->autor) && $mark->autor){ ?> <p class="marker-info"><?php echo __('Author', 'soundmap') . ': ' . $mark->autor; ?></br><?php } ?>
<hr class="clear">
<!--audio class="soundmap-audio-player not-processed" src="<?php echo $mark->files[0]['url'] ?>"></audio-->
<audio class="" src="<?php echo $mark->files[0]['url'] ?>" controls=controls style="max-width:100%;"></audio>
<audio class="" src="<?php echo $mark->files[0]['url'] ?>" controls=controls style="max-width:100%;" autoplay></audio>
<div class="marker-info">
<?php the_tags(__('Tags','soundmap') . ': ', ' | ', '</br>'); ?>
<?php echo __('Categories','soundmap') . ': '; the_category(' | '); ?>