duanshan188866 2019-05-07 09:52
浏览 43

如何用php函数更改默认的Map Location?

I am trying to change the default map location in my Submit listing page, It currently shows United Kingdom location which is not correct and I want to make it United State. I tried to add some gmap3 scripts to center the map with coordinates but its not working. I tried below codes.

<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>`

Below is the field code which is displaying the map by default, But when a location is entered in the input field then it loads the new location as per the input 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; ?>

Please check the screenshot and testing site URL: https://worthy.foundation/resources/submit-listings/ enter image description here

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度