PHP code example of dutchigor / cmb2-image-map

1. Go to this page and download the library: Download dutchigor/cmb2-image-map library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dutchigor / cmb2-image-map example snippets


$cmb = new_cmb2_box( array(
    'id'            => 'image_map_metabox',
    'title'         => 'Example',
    'object_types'  => array( 'post' ),
 ) );

$cmb->add_field( array(
    'id'            => 'my_img_map',
    'name'          => 'Test Image Map',
    'type'          => 'image_map',
    'base_type'     => 'map',
    'base_layer'    => 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}'
    'base_lat'      => 60.1699,
    'base_lng'      => 24.9384,
    'layer_options' => array( 
        'accessToken'   => 'your-token-here',
        'id'            => 'mapbox/streets-v11',
        'tileSize'      => 512,
        'zoomOffset'    => -1,
    ),
    'map_options'   => array(
        'maxZoom'       => 18,
    )
) );

$coordinates = get_post_meta( $post->ID, 'my_img_map', true )
flexmap_show_map([
  'center' => $coordinates['lat'] . ',' . $coordinates['lng']
]);