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 //Get variables form input values
latitude = 0; latitude = document.getElementById('sp_latitude').value;
longitude = 0; longitude = document.getElementById('sp_longitude').value;
//Initialize the map and add the Search control box //Initialize the map and add the Search control box
var map = L.map('sp-location-picker').setView([latitude, longitude], 15), var map = L.map('sp-location-picker').setView([latitude, longitude], 15),

View File

@@ -543,11 +543,11 @@ class SP_Admin_Setup_Wizard {
<tr> <tr>
<th scope="row"><?php _e( 'Address', 'sportspress' ); ?></th> <th scope="row"><?php _e( 'Address', 'sportspress' ); ?></th>
<td> <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> <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> <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="latitude" id="sp_latitude" class="sp-latitude" type="hidden" value="-37.8165647">
<input name="longitude" id="sp_longitude" class="sp-longitude" type="hidden" value="-73.82480799999996"> <input name="longitude" id="sp_longitude" class="sp-longitude" type="hidden" value="144.9475055">
</td> </td>
</tr> </tr>
</table> </table>

View File

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