Adaptadonlo para Soineka Paisaia

This commit is contained in:
Luca 2016-11-29 04:26:53 +01:00
parent 382723896a
commit 7ee760dc2b
4 changed files with 46 additions and 24 deletions

View File

@ -32,7 +32,7 @@ function the_map($css_id = 'map_canvas', $all_markers = FALSE, $options = array(
?>
<div class="<?php echo $css_id ?> soundmap-canvas">
<div style="height:100%;">
<div style="height:100%;" id="map-content">
</div>
</div>

View File

@ -14,13 +14,17 @@
},
init: function (selector, query){
this.map = L.map(selector,{center: [this.origin.lat, this.origin.lng], zoom: this.origin.zoom, scrollWheelZoom: false});
this.layers.SATELLITE = new L.Google();
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.map.addLayer(this.layers[this.mapType]);
this.map.addControl(
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,
@ -29,8 +33,8 @@
'Google Roadmap': this.layers.ROADMAP
}, {}
)
);
_.bindAll(this);
);*/
//_.bindAll(this);
options = {
type: 'POST',
@ -41,8 +45,11 @@
query: query
}
};
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){
@ -50,26 +57,27 @@
},
onMarkerClick: function(event){
self = window.Soundmap;
var id = event.target.feature.properties.id;
this.ajaxMarker = event.target;
if(this.infos[id]){
if (!_.isUndefined(this.callbacks.marker_click)){
this.callbacks.marker_click.apply(this, [this.infos[id], this.ajaxMarker]);
self.ajaxMarker = event.target;
if(self.infos[id]){
if (!_.isUndefined(self.callbacks.marker_click)){
self.callbacks.marker_click.apply(self, [self.infos[id], self.ajaxMarker]);
return;
}
}else{
options = {
type: 'POST',
url: this.ajaxurl,
context: this,
url: self.ajaxurl,
context: self,
data: {
action: 'soundmap-get-content',
id: id
}
};
// Use with PHP's wp_send_json_success() and wp_send_json_error()
$.ajax( options ).done(this.ajaxMarkerClick).fail(this.ajaxFail);
$.ajax( options ).done(self.ajaxMarkerClick).fail(self.ajaxFail);
}
},
@ -92,6 +100,7 @@
},
ajaxDone: function(response){
console.log('done'+response);
var self = this;
this.markers = L.geoJson(response.data,{
onEachFeature: function(feature, layer){
@ -107,6 +116,9 @@
$(document).ready(function(){
//soundmap.initMap();
soundmap.init('map-content','');
console.log('document.ready');
});
}(jQuery));

View File

@ -171,9 +171,11 @@ if (!class_exists('Soundmap')){
- Leaflet Google Plugin
- LeafletCSS
*/
wp_enqueue_script( 'google-maps', 'http://maps.google.com/maps/api/js?v=3.7&amp;sensor=false' ); // Google Maps
wp_enqueue_script('leafletjs','http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js',array(),'0.7.2',TRUE); // add Leaflet.js
wp_enqueue_style('leafletcss','http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css',array(),'0.7.2','all'); // add CSS Leaflet
//wp_enqueue_script( 'google-maps', 'http://maps.google.com/maps/api/js?v=3.7&amp;sensor=false' ); // Google Maps
wp_enqueue_script('mapboxjs','https://api.mapbox.com/mapbox.js/v2.2.4/mapbox.js',array(),'2.2.4',TRUE); // add Leaflet.js
//wp_enqueue_script('leafletjs','http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js',array(),'0.7.2',TRUE); // add Leaflet.js
wp_enqueue_style('mapboxcss','https://api.mapbox.com/mapbox.js/v2.2.4/mapbox.css',array(),'2.2.4','all'); // add CSS Leaflet
//wp_enqueue_style('leafletcss','http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css',array(),'0.7.2','all'); // add CSS Leaflet
wp_enqueue_script('leaflet-plugin-google', plugins_url('js/leaflet/plugins/Google.js', __FILE__), array('leafletjs', 'google-maps'), '0.7.2', TRUE);
}
@ -374,6 +376,8 @@ if (!class_exists('Soundmap')){
add_action('wp_ajax_soundmap_load_infowindow', array($this, 'load_infowindow'));
add_action('wp_ajax_soundmap-get-markers',array($this, 'soundmap_get_markers'));
add_action('wp_ajax_nopriv_soundmap-get-markers',array($this,'soundmap_get_markers'));
//add_action('wp_ajax_nopriv_soundmap-get-markers',array($this, 'soundmap_get_markers'));
add_action('wp_ajax_soundmap-get-content',array($this, 'soundmap_get_content'));
@ -489,10 +493,11 @@ if (!class_exists('Soundmap')){
}
function soundmap_get_markers(){
if (!isset($_POST['query']))
wp_send_json_error();
/*if (!isset($_POST['query']))
wp_send_json_error();*/
$q = $_POST['query'];
if (!is_array($q)) {$q=array($q); }
if (is_array($q)){
$options = array(
@ -524,9 +529,13 @@ if (!class_exists('Soundmap')){
$feature->properties = new stdclass();
$feature->properties->id = $post_id;
$feature->properties->title = $title;
/*$feature->properties = array();
$feature->properties['title']=$title;
$feature->properties['id']=$id;
$feature->properties['marker-color']="#ff00ff";*/
//$feature->properties['title']="ssss";
$feature_collection->features[] = $feature;
}
wp_send_json_success($feature_collection);
}
}

View File

@ -9,7 +9,8 @@
<?php echo apply_filters('the_content',get_the_content()) ?>
<?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="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>
<div class="marker-info">
<?php the_tags(__('Tags','soundmap') . ': ', ' | ', '</br>'); ?>
<?php echo __('Categories','soundmap') . ': '; the_category(' | '); ?>