无法自动完成地理位置定位,也无法绘制地图

时间:2019-06-27 04:37:39

标签: php wordpress google-maps-api-3 meta-boxes

无论我做什么,我都无法让Geolocation为我的meta框字段做任何事情。自动填充字段永远不会在以“地址”作为ID的字段上弹出任何内容。似乎相关,如果我添加了地图字段类型,则帖子输入页面会显示粘贴在都柏林的字段地图,然后单击“查找地址”按钮没有任何作用。

但是它仅在我更改'type'=>'osm'时有效,但我不喜欢此地图。 我创建了api密钥和有效的结算帐户。

感觉好像我缺少一些基本知识,因为与地理相关的功能都没有为我激活。很抱歉询问基本内容。那我该怎么解决呢?

下面是我的整个代码:

<?php
/***** Include metabox *****/
function location_register_meta_boxes( $meta_boxes ) {
  $prefix = 'tuyen_custom_';
  $meta_boxes[] = array(
    'id'         => 'personal',
    'title'      => 'Option Google Maps',
    'post_types' => 'dia-diem',
    'context'    => 'normal',
    'status' => 'publish',
    'priority'   => 'high',
    'fields' => array(
        array(
            'id'   => $prefix . 'address',
            'name' => 'Address Name',
            'desc'  => 'Address Name Text',
            'type' => 'text',
        ),
        array(
            'id'            => $prefix . 'map',
            'name'          => 'Geolocation map',
            'type'          => 'map',
            // 'type'          => 'osm',
            'address_field' => $prefix . 'address',
            'std'           => '16.063220, 108.205881',
            'api_key'       => 'xxxxxx',
        ),
    )
  );
  return $meta_boxes;
}
add_filter( 'rwmb_meta_boxes', 'location_register_meta_boxes' );
?>

0 个答案:

没有答案