First commit to switch to Openstreetmaps

This commit is contained in:
savvasha
2019-02-16 12:42:34 +02:00
parent 5020512242
commit edd09a60ce
9 changed files with 658 additions and 0 deletions

View File

@@ -37,6 +37,7 @@ class SP_Admin_Assets {
if ( in_array( $screen->id, sp_get_screen_ids() ) ) {
// Admin styles for SP pages only
wp_enqueue_style( 'jquery-chosen', SP()->plugin_url() . '/assets/css/chosen.css', array(), '1.1.0' );
wp_enqueue_style( 'leaflet_stylesheet', SP()->plugin_url() . '/assets/css/leaflet.css', array(), '1.4.0' );
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_style( 'sportspress-admin', SP()->plugin_url() . '/assets/css/admin.css', array(), SP_VERSION );
} elseif ( strpos( $screen->id, 'sportspress-config' ) !== false ) {
@@ -85,6 +86,7 @@ class SP_Admin_Assets {
wp_register_script( 'jquery-fitvids', SP()->plugin_url() . '/assets/js/jquery.fitvids.js', array( 'jquery' ), '1.1', true );
wp_register_script( 'google-maps', '//tboy.co/maps_js' );
wp_register_script( 'leaflet_js', SP()->plugin_url() . '/assets/js/leaflet.js', array(), '1.4.0' );
wp_register_script( 'jquery-locationpicker', SP()->plugin_url() . '/assets/js/locationpicker.jquery.js', array( 'jquery', 'google-maps' ), '0.1.6', true );
@@ -133,6 +135,7 @@ class SP_Admin_Assets {
// Edit venue pages
if ( in_array( $screen->id, array( 'edit-sp_venue' ) ) ) {
wp_enqueue_script( 'google-maps' );
wp_enqueue_script( 'leaflet_js' );
wp_enqueue_script( 'jquery-locationpicker' );
wp_enqueue_script( 'sportspress-admin-locationpicker' );
}

View File

@@ -116,8 +116,23 @@ class SP_Admin_Taxonomies {
<label for="term_meta[sp_address]"><?php _e( 'Address', 'sportspress' ); ?></label>
<input type="text" class="sp-address" name="term_meta[sp_address]" id="term_meta[sp_address]" value="">
<p><div class="sp-location-picker"></div></p>
<p><div id="mapDiv" style="width: 95%; height: 320px"></div></p>
<p><?php _e( "Drag the marker to the venue's location.", 'sportspress' ); ?></p>
</div>
<script>
// position we will use later
var lat = <?php echo $latitude;?>;
var lon = <?php echo $longitude;?>;
// initialize map
map = L.map('mapDiv').setView([lat, lon], 15);
// set map tiles source
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors',
maxZoom: 15,
}).addTo(map);
// add marker to the map
marker = L.marker([lat, lon],{draggable: true, autoPan: true}).addTo(map);
</script>
<div class="form-field">
<label for="term_meta[sp_latitude]"><?php _e( 'Latitude', 'sportspress' ); ?></label>
<input type="text" class="sp-latitude" name="term_meta[sp_latitude]" id="term_meta[sp_latitude]" value="<?php echo esc_attr( $latitude ); ?>">