我正在尝试在“提交列表”页面中更改默认地图位置,当前显示的英国位置不正确,我希望将其设置为美国。我尝试添加一些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; ?>
请检查屏幕截图和测试网站的网址:https://worthy.foundation/resources/submit-listings/