Compare commits

...

4 Commits

3 changed files with 58 additions and 19 deletions

View File

@ -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 &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
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,17 @@
this.map.panTo(_latlng);
this.marker.addEventListener('dragend', this.markerDrag, this);
}
_.bindAll(this);
//_.bindAll(this);
//init elements
this.file_frame = wp.media({
multiple: false,
library: {
type: 'audio'
}
});
console.log(this.file_frame)
console.log('iniciando file_frame')
this.initEvents();
;
@ -51,7 +70,7 @@
initEvents: function(){
$('#add_files').bind('click', this.openMediaManager);
this.file_frame.on('select',this.mediaSelected, this);
wp.media.frames.file_frame.on('select',this.mediaSelected, this);
$('.delete-att-item').live('click', this.removeMedia);
},
@ -59,13 +78,15 @@
$(event.currentTarget).parents('.soundmap-attach-item').remove();
},
openMediaManager: function(event){
this.file_frame = wp.media.frames.file_frame
event.preventDefault();
if ( this.file_frame ){
this.file_frame.open();
return;
};
}
},
mediaSelected: function(event){
this.file_frame = wp.media.frames.file_frame
var attachment = this.file_frame.state().get('selection').first().toJSON();
var _cT = _.template(this.attachTemplate);
var _o = _cT({
@ -106,4 +127,4 @@
soundmap.initMap();
});
}(jQuery));
}(jQuery));

View File

@ -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));
}(jQuery));

View File

@ -47,7 +47,7 @@ if (!class_exists('Soundmap')){
'not_found' => __('No markers found', 'soundmap'),
'not_found_in_trash' => __('No markers found in Trash', 'soundmap'),
'parent_item_colon' => '',
'menu_name' => 'Markers'
'menu_name' => 'Markers'
);
$args = array(
@ -60,6 +60,7 @@ if (!class_exists('Soundmap')){
'rewrite' => array( 'slug' => 'marker', 'with_front' => false ),
'capability_type' => 'post',
'has_archive' => true,
'show_in_rest' => true,
'hierarchical' => false,
'menu_position' => 5,
'register_meta_box_cb' => array($this, 'metaboxes_register_callback'),
@ -82,7 +83,8 @@ if (!class_exists('Soundmap')){
add_meta_box('soundmap-map', __("Place the Marker", 'soundmap'), array($this, 'map_meta_box'), 'marker', 'normal', 'high');
add_meta_box('soundmap-media-info', __("Info", 'soundmap'), array($this,'info_meta_box'), 'marker', 'side', 'high');
add_meta_box('soundmap-media-attachments', __("Media files attached.", 'soundmap'), array($this, 'attachments_meta_box'), 'marker', 'side', 'high');
add_meta_box('soundmap-email', __("Uploader Mail", 'soundmap'), array($this, 'email_meta_box'), 'marker', 'side', 'low');
// Ya no es necesario
//add_meta_box('soundmap-email', __("Uploader Mail", 'soundmap'), array($this, 'email_meta_box'), 'marker', 'side', 'low');
} //metaboxes_register_callback
function email_meta_box(){
@ -172,11 +174,11 @@ if (!class_exists('Soundmap')){
- LeafletCSS
*/
//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);
//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','https://unpkg.com/leaflet@1.3.4/dist/leaflet.js',array(),'1.3.4',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',"https://unpkg.com/leaflet@1.3.4/dist/leaflet.css",array(),'1.3.4','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);
}
function wp_enqueue_scripts(){
@ -214,6 +216,7 @@ if (!class_exists('Soundmap')){
}else if($hook == 'settings_page_soundmap-options-menu'){
$this->enqueue_map_scripts();
wp_enqueue_script('underscore');
wp_enqueue_script('soundmap-config', plugins_url('js/soundmap.config.js', __FILE__), array(), '0.1', TRUE);
wp_enqueue_style('soundmap-config-css', plugins_url('css/soundmap.config.css', __FILE__), array(), '0.1', 'all');
@ -333,7 +336,8 @@ if (!class_exists('Soundmap')){
};
}else{
delete_post_meta($post_id, 'soundmap_attachments_id');
add_post_meta($post_id, 'soundmap_attachments_id', 'null');
// PORQUE? esto genera un null
//add_post_meta($post_id, 'soundmap_attachments_id', 'null');
};
delete_transient( 'soundmap_JSON_markers' );