Set default coordinates

This commit is contained in:
savvasha
2019-02-21 23:07:02 +02:00
parent 3986a8566e
commit 39b7544270
3 changed files with 10 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
//Initialize variables
latitude = 0;
longitude = 0;
//Get variables form input values
latitude = document.getElementById('sp_latitude').value;
longitude = document.getElementById('sp_longitude').value;
//Initialize the map and add the Search control box
var map = L.map('sp-location-picker').setView([latitude, longitude], 15),

View File

@@ -543,11 +543,11 @@ class SP_Admin_Setup_Wizard {
<tr>
<th scope="row"><?php _e( 'Address', 'sportspress' ); ?></th>
<td>
<input name="address" id="sp_address" class="sp-address" type="text">
<input name="address" id="sp_address" class="sp-address" type="text" value="Marvel Stadium, Melbourne">
<div id="sp-location-picker" style="width: 95%; height: 320px"></div>
<p class="description"><?php _e( "Drag the marker to the venue's location.", 'sportspress' ); ?></p>
<input name="latitude" id="sp_latitude" class="sp-latitude" type="hidden" value="40.7324319">
<input name="longitude" id="sp_longitude" class="sp-longitude" type="hidden" value="-73.82480799999996">
<input name="latitude" id="sp_latitude" class="sp-latitude" type="hidden" value="-37.8165647">
<input name="longitude" id="sp_longitude" class="sp-longitude" type="hidden" value="144.9475055">
</td>
</tr>
</table>

View File

@@ -103,14 +103,14 @@ class SP_Admin_Taxonomies {
$term = reset( $terms );
$t_id = $term->term_id;
$term_meta = get_option( "taxonomy_$t_id" );
$latitude = sp_array_value( $term_meta, 'sp_latitude', '40.7324319' );
$longitude = sp_array_value( $term_meta, 'sp_longitude', '-73.82480799999996' );
$latitude = sp_array_value( $term_meta, 'sp_latitude', '-37.8165647' );
$longitude = sp_array_value( $term_meta, 'sp_longitude', '144.9475055' );
$address = sp_array_value( $term_meta, 'sp_address', '' );
endif;
// Sanitize latitude and longitude, fallback to default.
if( ! is_numeric( $latitude) || ! is_numeric( $longitude) ):
$latitude = '40.7324319';
$longitude = '-73.82480799999996';
$latitude = '-37.8165647';
$longitude = '144.9475055';
endif;
?>
<div class="form-field">