Я пытаюсь изменить местоположение на карте по умолчанию на странице отправки в мой список. В настоящее время в нем отображается неверное местоположение в Соединенном Королевстве, и я хочу сделать его в Соединенных Штатах. Я попытался добавить несколько скриптов gmap3, чтобы центрировать карту по координатам, но она не работает. Я попробовал ниже коды.
<script>
$('#googleMap').gmap3({
map:{
options:{
center: [-33, 151],//place the latitude and longitude of map's center position
zoom: 8
}
},
marker:{
latLng: [37, -95],// place the latitude and longitude of the marker
callback: function(){
$(this).css('border', '1px solid red');
}
}
});
</script>`
Ниже приведен код поля, который отображает карту по умолчанию, но когда в поле ввода вводится местоположение, оно загружает новое местоположение в соответствии со значением VALUE.
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
global $post;
$job_id = !empty($_GET['job_id']) ? $_GET['job_id'] : '';
$geo_latitude = get_post_meta( $job_id, 'geolocation_lat', true );
$geo_longitude = get_post_meta( $job_id, 'geolocation_long', true );
?>
<div class="apuslisting-location-field">
<div class="apuslisting-location-field-inner">
<input type="text" class="input-text input-location-field" name="<?php echo esc_attr( isset( $field['name'] ) ? $field['name'] : $key ); ?>"<?php if ( isset( $field['autocomplete'] ) && false === $field['autocomplete'] ) { echo ' autocomplete="off"'; } ?> id="<?php echo esc_attr( $key ); ?>" placeholder="<?php echo esc_attr( $field['placeholder'] ); ?>" value="<?php echo isset( $field['value'] ) ? esc_attr( $field['value'] ) : ''; ?>" maxlength="<?php echo ! empty( $field['maxlength'] ) ? $field['maxlength'] : ''; ?>" <?php if ( ! empty( $field['required'] ) ) echo 'required'; ?> />
<span class="find-me-location"><?php get_template_part( 'assets/images/icon/location' ); ?></span>
</div>
<div class="apuslisting-location-field-map" style="height: 300px;"></div>
<div class="row">
<div class="col-sm-6">
<fieldset>
<label><?php esc_html_e( 'Latitude', 'apuslisting' ); ?></label>
<div class="field">
<input class="geo_latitude" name="geo_latitude" value="<?php echo esc_attr( $geo_latitude); ?>" type="text">
</div>
</fieldset>
</div>
<div class="col-sm-6">
<fieldset>
<label><?php esc_html_e( 'Longitude', 'apuslisting' ); ?></label>
<div class="field">
<input class="geo_longitude" name="geo_longitude" value="<?php echo esc_attr( $geo_longitude ); ?>" type="text">
</div>
</fieldset>
</div>
</div>
</div>
<?php if ( ! empty( $field['description'] ) ) : ?><small class="description"><?php echo trim($field['description']); ?></small><?php endif; ?>
Пожалуйста, проверьте скриншот и URL сайта тестирования: https://worthy.foundation/resources/submit-listings/
