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 class="<?php echo $css_id ?> soundmap-canvas">
<div style="height:100%;"> <div style="height:100%;" id="map-content">
</div> </div>
</div> </div>

View File

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

View File

@ -171,9 +171,11 @@ if (!class_exists('Soundmap')){
- Leaflet Google Plugin - Leaflet Google Plugin
- LeafletCSS - LeafletCSS
*/ */
wp_enqueue_script( 'google-maps', 'http://maps.google.com/maps/api/js?v=3.7&amp;sensor=false' ); // Google Maps //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_script('mapboxjs','https://api.mapbox.com/mapbox.js/v2.2.4/mapbox.js',array(),'2.2.4',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('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); 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_load_infowindow', array($this, 'load_infowindow'));
add_action('wp_ajax_soundmap-get-markers',array($this, 'soundmap_get_markers')); 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')); add_action('wp_ajax_soundmap-get-content',array($this, 'soundmap_get_content'));
@ -489,10 +493,11 @@ if (!class_exists('Soundmap')){
} }
function soundmap_get_markers(){ function soundmap_get_markers(){
if (!isset($_POST['query'])) /*if (!isset($_POST['query']))
wp_send_json_error(); wp_send_json_error();*/
$q = $_POST['query']; $q = $_POST['query'];
if (!is_array($q)) {$q=array($q); }
if (is_array($q)){ if (is_array($q)){
$options = array( $options = array(
@ -524,9 +529,13 @@ if (!class_exists('Soundmap')){
$feature->properties = new stdclass(); $feature->properties = new stdclass();
$feature->properties->id = $post_id; $feature->properties->id = $post_id;
$feature->properties->title = $title; $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; $feature_collection->features[] = $feature;
} }
wp_send_json_success($feature_collection); wp_send_json_success($feature_collection);
} }
} }

View File

@ -9,7 +9,8 @@
<?php echo apply_filters('the_content',get_the_content()) ?> <?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 } ?> <?php if(isset($mark->autor) && $mark->autor){ ?> <p class="marker-info"><?php echo __('Author', 'soundmap') . ': ' . $mark->autor; ?></br><?php } ?>
<hr class="clear"> <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"> <div class="marker-info">
<?php the_tags(__('Tags','soundmap') . ': ', ' | ', '</br>'); ?> <?php the_tags(__('Tags','soundmap') . ': ', ' | ', '</br>'); ?>
<?php echo __('Categories','soundmap') . ': '; the_category(' | '); ?> <?php echo __('Categories','soundmap') . ': '; the_category(' | '); ?>