Plugin Directory

Changeset 2368995


Ignore:
Timestamp:
08/25/2020 08:58:49 PM (6 years ago)
Author:
tempranova
Message:

update to 3.0.0

Location:
wp-mapbox-gl-js
Files:
2460 added
3 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • wp-mapbox-gl-js/trunk/admin/class-wp-mapbox-gl-js-admin.php

    r2005792 r2368995  
    7070        wp_enqueue_style('wp_mapbox_gl_js_react-css', plugin_dir_url( __FILE__ ) . '/wp-mapmaker/public/css/style.css', array(), mt_rand(10,1000), 'all' );
    7171        wp_enqueue_style( $this->wp_mapbox_gl_js, plugin_dir_url( __FILE__ ) . '/css/wp-mapbox-gl-js-admin.css', array(), $this->version, 'all' );
    72 
     72        wp_enqueue_style('wp_mapbox_gl_js_balloon', plugin_dir_url( __FILE__ ) . '/css/balloon.css', array(), mt_rand(10,1000), 'all' );
     73        wp_enqueue_style('wp_mapbox_gl_js_rc_slider', plugin_dir_url( __FILE__ ) . '/css/rc-slider.min.css', array(), mt_rand(10,1000), 'all' );
    7374    }
    7475
     
    8687
    8788        if( is_object( $screen ) && $cpt == $screen->post_type ){
    88                     wp_enqueue_script('wp_mapbox_gl_js_react', plugin_dir_url( __FILE__ ) . '/wp-mapmaker/build/static/js/main.8802e6f7.js', '', '', true);
    89                     wp_enqueue_script( $this->wp_mapbox_gl_js, plugin_dir_url( __FILE__ ) . '/js/wp-mapbox-gl-js-admin.js', array('jquery'), $this->version, 'all' );
     89                    // PROD
     90                    // if (!in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) {
     91                    // code for localhost here
     92                        // PROD
     93                        $JSfiles = scandir(dirname(__FILE__) . '/wp-mapmaker/build/static/js/');
     94                        $react_js_to_load = '';
     95                        foreach($JSfiles as $filename) {
     96                            if(strpos($filename,'.js')&&!strpos($filename,'.js.map')) {
     97                                $react_js_to_load = plugin_dir_url( __FILE__ ) . 'wp-mapmaker/build/static/js/' . $filename;
     98                            }
     99                        }
     100                    // } else {
     101                    //  $react_js_to_load = 'http://localhost:3000/static/js/bundle.js';
     102                    // }
     103                    // React dynamic loading
     104                    wp_register_script('wp_mapbox_gl_js_react', $react_js_to_load, '', mt_rand(10,1000), true);
     105                    wp_localize_script('wp_mapbox_gl_js_react', 'params', array(
     106                        'nonce' => wp_create_nonce('wp_rest'),
     107                        'nonce_verify' => wp_verify_nonce($_REQUEST['X-WP-Nonce'], 'wp_rest')
     108                    ));
     109                    wp_enqueue_script( 'wp_mapbox_gl_js_react' );
     110
     111                    // Loading for auxiliary maps
     112                    wp_enqueue_script('mapbox_gl_js', 'https://api.mapbox.com/mapbox-gl-js/v1.12.0/mapbox-gl.js', array('jquery'), '', false);
     113                    wp_enqueue_script( $this->wp_mapbox_gl_js, plugin_dir_url( __FILE__ ) . '/js/wp-mapbox-gl-js-admin.js', array('mapbox_gl_js'), mt_rand(10,1000), 'all' );
    90114        }
    91115
    92116    } else {
    93             wp_enqueue_script('mapbox_gl_js', 'https://api.tiles.mapbox.com/mapbox-gl-js/v0.43.0/mapbox-gl.js', array(), '', false);
     117            wp_enqueue_script('mapbox_gl_js', 'https://api.mapbox.com/mapbox-gl-js/v1.12.0/mapbox-gl.js', array(), '', false);
    94118            wp_enqueue_script( $this->wp_mapbox_gl_js, plugin_dir_url( __FILE__ ) . '/js/wp-mapbox-gl-js-admin.js', array('jquery'), $this->version, 'all' );
    95119        }
     
    106130            array(
    107131                'labels' => array(
    108                     'name' => 'Mapbox Maps',
    109                     'singular_name' => 'Mapbox Map',
     132                    'name' => 'GL JS Maps',
     133                    'singular_name' => 'GL JS Map',
    110134                    'add_new' => 'Add New',
    111135                    'add_new_item' => 'Add New Map',
     
    126150                    'slug' => 'maps', 'with_front' => TRUE
    127151                ),
    128                 'supports' => array( 'title' ),
    129                 'taxonomies' => array( '' ),
     152                'supports' => array( 'title','editor','thumbnail','revisions','custom-fields','excerpt'),
     153                'taxonomies' => array( 'gl_js_maps_category' ),
    130154                'menu_icon' => 'dashicons-admin-site',
    131155                'has_archive' => true
    132156            )
    133157        );
     158            register_taxonomy( 'gl_js_maps_category', 'gl_js_maps', array(
     159                    'labels' => array(
     160                            'name' => 'Maps Categories',
     161                            'singular_name' => 'Maps Categories',
     162                            'add_new' => 'Add New Category',
     163                            'add_new_item' => 'Add New Map Category',
     164                            'edit' => 'Edit',
     165                            'edit_item' => 'Edit Map Category',
     166                            'new_item' => 'New Map Category',
     167                            'view' => 'View',
     168                            'view_item' => 'View Map Category',
     169                            'search_items' => 'Search Category',
     170                            'not_found' => 'No Map Categories found',
     171                            'not_found_in_trash' => 'No Categories found in Trash',
     172                            'parent' => 'Parent Category'
     173                    ),
     174                    'hierarchical' => true,
     175                    'show_admin_column' => true
     176            ) );
     177
     178            $set = get_option( 'post_type_rules_flushed_gl_js_maps' );
     179            if ( $set !== true ){
     180            flush_rewrite_rules( false );
     181            update_option( 'post_type_rules_flushed_gl_js_maps', true );
     182            }
     183
     184            // Disable gutenberg
     185            function wp_mapbox_gl_js_disable_gutenberg($is_enabled, $post_type) {
     186                if ($post_type === 'gl_js_maps')  {
     187                    return false;
     188                }
     189                return $is_enabled;
     190            }
     191            add_filter('use_block_editor_for_post_type', 'wp_mapbox_gl_js_disable_gutenberg', 10, 2);
    134192
    135193            // Create default option
     
    184242
    185243                <div class="wp_mapbox_gl_js_editor_content_container">
    186                     <?php wp_editor('', 'wp_mapbox_gl_js_editor_content', array('quicktags'=>false)); ?>
     244                    <?php wp_editor('', 'wp_mapbox_gl_js_editor_content' ); ?>
    187245                </div>
    188246
     
    208266                if($map_object) { ?>
    209267                    [wp_mapbox_gl_js map_id="<?php echo $post->ID; ?>"]
    210                     <p><em><a href="https://www.mapster.me/wp-mapbox-gl-js/docs/map-creator/" target="_blank">Need help?</a></em></p>
     268                    <p><em><a href="http://mapster.me/wp-mapbox-gl-js" target="_blank">Need help?</a></em></p>
    211269                <?php } else { ?>
    212                     <p><em>A code you can use to add your map to posts and widgets will appear here after you save your map.</em></pre></p>
     270                    <p>A code you can use to add your map to posts and widgets will appear here after you save your map.</p>
    213271                <?php }
    214272            }
     
    230288            ?>
    231289
    232             <p><input type="checkbox" id="wp_mapbox_gl_js_location_search" /> Location Search</p>
     290            <p><input type="checkbox" id="wp_mapbox_gl_js_location_search" /> Location Search </p>
     291            <p><input type="checkbox" id="wp_mapbox_gl_js_controls_geolocater" /> Geolocate <span data-balloon-length="medium" data-balloon="Your website needs HTTPS for the geolocator to appear." data-balloon-pos="left" class="wp_mapbox_gl_js_tooltip">?</span></p>
    233292            <p><input type="checkbox" id="wp_mapbox_gl_js_distance" /> Distance scale</p>
    234293            <p><input type="checkbox" id="wp_mapbox_gl_js_zoompan" /> Zoom & Pan</p>
    235294            <p><input type="checkbox" id="wp_mapbox_gl_js_fullscreen" /> Fullscreen</p>
    236295            <p><input type="checkbox" id="wp_mapbox_gl_js_directions" /> Directions</p>
     296            <p id="wp_mapbox_gl_js_directions_pre_fill_checkbox">
     297                <input type="checkbox" id="wp_mapbox_gl_js_directions_pre_fill_input" />
     298                Pre-Fill Directions <span data-balloon="Whatever you put into the Directions Input will be saved." data-balloon-length="medium" data-balloon-pos="left" class="wp_mapbox_gl_js_tooltip">?</span>
     299            </p>
     300            <p><input type="checkbox" id="wp_mapbox_gl_js_scroll_zoom" /> Scroll on Zoom</p>
     301            <p><input type="checkbox" id="wp_mapbox_gl_js_category_filter" /> Custom Feature Filter <span data-balloon-length="medium" data-balloon="Allows you to create custom categories to filter map features." data-balloon-pos="left" class="wp_mapbox_gl_js_tooltip">?</span></p>
     302                <div id="wp_mapbox_gl_js_category_creator">
     303                    <div>
     304              <input type="text" class="widefat" id="category_filter_input" />
     305              <button class="button" id="category_filter_input_submit">Create Category</button>
     306                    </div>
     307                </div>
     308            <p><input type="checkbox" id="wp_mapbox_gl_js_layer_filter" /> Custom Layer Filter <span data-balloon-length="medium" data-balloon="Allows you to create filter Mapbox style layers." data-balloon-pos="left" class="wp_mapbox_gl_js_tooltip">?</span></p>
     309                <div id="wp_mapbox_gl_js_layer_creator">
     310                    <div>
     311                        <select multiple="multiple" id="wp_mapbox_gl_js_layer_select">
     312                        </select>
     313                    </div>
     314                </div>
     315            <p><input type="checkbox" id="wp_mapbox_gl_js_location_sidebar" /> Location Sidebar <span data-balloon-length="medium" data-balloon="This will create a list of locations on the side of your map." data-balloon-pos="left" class="wp_mapbox_gl_js_tooltip">?</span></p>
     316            <p><input type="checkbox" id="wp_mapbox_gl_js_cluster_markers" /> Cluster Markers</p>
    237317
    238318            <?php
     
    266346            <p>OR enter your own custom style.</p>
    267347            <input type="text" class='widefat' id="wp-mapbox-gl-js-custom-style" />
    268             <p><em>Confused? <a href="https://www.mapster.me/wp-mapbox-gl-js/docs/map-creator/" target="_blank">Watch our quick help video!</a></em></p>
     348            <p><em>Confused? <a href="http://mapster.me/wp-mapbox-gl-js" target="_blank">Watch our quick help videos!</a></em></p>
     349            <p><strong>Preset Initial Map View</strong></p>
     350            <input type="checkbox" id="wp-mapbox-gl-js-set-current-map-view" checked="checked"> Set to current map view<br />
     351            <?php if(get_post_meta( $post->ID, 'wp_mapbox_gl_js_hidden_in_post', true)) { ?>
     352                <input type="checkbox" id="wp-mapbox-gl-js-set-current-map-view-in-post" name="wp_mapbox_gl_js_hidden_in_post" value="checked"> Show map in post<br /><br />
     353            <?php } else { ?>
     354                <input type="checkbox" id="wp-mapbox-gl-js-set-current-map-view-in-post" name="wp_mapbox_gl_js_hidden_in_post" value="checked" checked="checked"> Show map in post<br /><br />
     355            <?php } ?>
    269356            <button class="wp-mapbox-gl-js-advanced-options-button button">Advanced options</button>
    270357            <div class="wp-mapbox-gl-js-advanced-options">
    271                 <p><strong>Preset Initial Map View</strong></p>
    272                 <input type="checkbox" id="wp-mapbox-gl-js-set-current-map-view"> Set to current map view<br />
     358                <p><input type="checkbox" class='widefat' id="wp-mapbox-gl-js-marker-overlap" /> Hide Markers on Overlap<br /></p>
    273359                <p>Center<br /><small><em>Coordinate location to start the map. In format "-123.40, 76.40".</small></em></p>
    274360                <input type="text" class='widefat' id="wp-mapbox-gl-js-center" />
     
    279365                <p>Pitch<br /><small><em>This affects the "angle" the view sees the map from. Can be a number from 0 to 60.</small></em></p>
    280366                <input type="text" class='widefat' id="wp-mapbox-gl-js-pitch" />
     367                <p><button class='button' id="wp-mapbox-gl-js-marker-hide" /> Hide marker popups on load <button></p>
    281368            </div>
    282369            <?php
    283370        }
     371
     372        add_meta_box(
     373            'wp_mapbox_gl_js_dataset_management',
     374            'GL JS Dataset Management',
     375            'wp_mapbox_gl_js_dataset_management',
     376            'gl_js_maps',
     377            'side',
     378            'low'
     379        );
     380
     381        function wp_mapbox_gl_js_dataset_management( $post, $metabox ) {
     382
     383            $dataset_id = str_replace('"', "", get_post_meta($post->ID,'wp_mapbox_gl_js_dataset_id', true));
     384
     385            if(get_option('mapbox_gl_js_secret_access_token')&&get_option('mapbox_gl_js_secret_access_token')!=='') {
     386                $datasetOK = false;
     387                echo $dataset_id;
     388                if($dataset_id!=="") {
     389                    $curl = curl_init();
     390                    curl_setopt ($curl, CURLOPT_URL, "https://api.mapbox.com/datasets/v1/".get_option( 'mapbox_gl_js_username' )."/".$dataset_id."?access_token=".get_option( 'mapbox_gl_js_secret_access_token' ));
     391                    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     392                    $results = curl_exec ($curl);
     393                    curl_close ($curl);
     394                    $results = json_decode($results);
     395                    if($results->id) {
     396                        $datasetOK = true;
     397                    }
     398                }
     399                if($dataset_id==""||!$datasetOK) {
     400                    ?>
     401                    <div>
     402                        <input type="hidden" id="wp_mapbox_gl_js_username" value="<?php echo get_option( 'mapbox_gl_js_username' ); ?>" />
     403                        <input type="hidden" id="wp_mapbox_gl_js_secret_token" value="<?php echo get_option( 'mapbox_gl_js_secret_access_token' ); ?>" />
     404                        <p>This post is not associated with any Mapbox dataset.</p>
     405                        <p>If you would like to associate it with a Mapbox feature from one of your datasets, select below.</p>
     406                        <select id="wp_mapbox_gl_js_dataset_list" name="wp_mapbox_gl_js_dataset_list">
     407                            <option value="">(no dataset selected)</option>
     408                            <?php
     409                                $curl = curl_init();
     410                                curl_setopt ($curl, CURLOPT_URL, "https://api.mapbox.com/datasets/v1/".get_option( 'mapbox_gl_js_username' )."?access_token=".get_option( 'mapbox_gl_js_secret_access_token' ));
     411                                curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     412
     413                                $results = curl_exec ($curl);
     414                                curl_close ($curl);
     415                                $results = json_decode($results);
     416                                foreach($results as $result) {
     417                                    echo '<option value="'.$result->id.'">'.$result->name.'</option>';
     418                                }
     419                            ?>
     420                        </select>
     421                        <div class="wp_mapbox_gl_js_features">
     422                            <h3>Add Features to Mapbox</h3>
     423                            <button class="button" id="wp-mapbox-gl-js-to-dataset-add">Add features to Mapbox</button>
     424                            <div id="wp-mapbox-gl-js-from-dataset-update-updated"><span>Updated Mapbox features.</div>
     425                            <h3>Link Single Feature to Mapbox</h3>
     426                            <p><small>See documentation for help on linking features.</small></p>
     427                            <select id="wp_mapbox_gl_js_feature_list" name="wp_mapbox_gl_js_feature_list"></select>
     428                            <input type="hidden" id="wp_mapbox_gl_js_dataset_id_set" name="wp_mapbox_gl_js_dataset_id_set" />
     429                            <button class="button" id="set_wp_mapbox_gl_js_feature">Link feature to post</button>
     430                            <div class="wp_mapbox_gl_js_dataset_error"></div>
     431                        </div>
     432                    </div>
     433                    <?php
     434                } else {
     435                    $curl = curl_init();
     436                    curl_setopt ($curl, CURLOPT_URL, "https://api.mapbox.com/datasets/v1/".get_option( 'mapbox_gl_js_username' )."/".$dataset_id."?access_token=".get_option( 'mapbox_gl_js_secret_access_token' ));
     437                    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     438                    $results = curl_exec ($curl);
     439                    curl_close ($curl);
     440                    $results = json_decode($results);
     441
     442                    $map_object = json_decode(get_post_meta( $post->ID, 'wp_mapbox_gl_js_map_object', true ));
     443                    $feature_ids = [];
     444                    foreach($map_object->mapData as $feature) {
     445                        array_push($feature_ids, $feature->id);
     446                    }
     447
     448                    ?>
     449                    <div>
     450                        <input type="hidden" id="wp_mapbox_gl_js_username" value='<?php echo get_option( 'mapbox_gl_js_username' ); ?>' />
     451                        <input type="hidden" id="wp_mapbox_gl_js_secret_token" value='<?php echo get_option( 'mapbox_gl_js_secret_access_token' ); ?>' />
     452                        <input type="hidden" id="wp_mapbox_gl_js_features" value='<?php echo json_encode($feature_ids); ?>' />
     453                        <input type="hidden" id="wp_mapbox_gl_js_dataset" value='<?php echo $dataset_id; ?>' />
     454                        <p>This shows the features linked in this map as they currently appear in Mapbox.</p>
     455                        <p>Dataset: <?php echo $results->name; ?></p>
     456                        <div id="wp-mapbox-gl-js-dataset-map"></div>
     457                        <br />
     458                        <button id="wp-mapbox-gl-js-to-dataset-update" class="button">Update Mapbox features</button>
     459                        <div id="wp-mapbox-gl-js-to-dataset-update-updated">Updated! Mapbox will take five minutes to update, but it worked!</div>
     460                        <br />
     461                        <button id="wp-mapbox-gl-js-to-dataset-delete" class="button">Delete Mapbox features</button>
     462                        <div id="wp-mapbox-gl-js-to-dataset-update-deleted">Deleted! Mapbox will take five minutes to update, but it worked!</div>
     463                        <br /><br />
     464                        <button id="wp-mapbox-gl-js-from-dataset-update" class="button">Update post's features</button>
     465                        <div id="wp-mapbox-gl-js-from-dataset-update-updated"><span>Updated <span id="wp-mapbox-gl-js-from-dataset-update-updated-number">0</span> features!</span> This post will save and reload in a moment.</div>
     466                    </div>
     467
     468                    <?php
     469                }
     470            } else {
     471                echo 'You must add your username and secret token in WP Mapbox Settings to use dataset management.';
     472            }
     473        }
    284474    }
    285475
     
    290480     */
    291481    public function wp_mapbox_gl_js_admin_menu() {
    292         add_menu_page('Maps Settings', 'Maps Settings', 'manage_options', 'wp-mapbox-gl-js-settings', function() { include 'wp-mapbox-gl-js-settings.php'; } );
     482        add_menu_page('WP Mapbox', 'WP Mapbox', 'manage_options', 'wp-mapbox-gl-js-settings' );
     483        add_submenu_page('wp-mapbox-gl-js-settings', 'WP Mapbox Settings', 'WP Mapbox Settings', 'manage_options', 'wp-mapbox-gl-js-settings', function() { include 'partials/wp-mapbox-gl-js-settings.php'; } );
     484        add_submenu_page('wp-mapbox-gl-js-settings','WP Mapbox Tools', 'WP Mapbox Tools', 'manage_options', 'wp-mapbox-gl-js-tools', function() { include 'partials/wp-mapbox-gl-js-tools.php'; } );
    293485    }
    294486
     
    300492    public function move_above_editor() {
    301493        global $post, $wp_meta_boxes;
    302         do_meta_boxes(get_current_screen(), 'gl_js_maps_context', $post);
    303         unset($wp_meta_boxes['gl_js_maps']['gl_js_maps_context']);
     494        do_meta_boxes(get_current_screen(), 'advanced', $post);
     495        unset($wp_meta_boxes['gl_js_maps']['advanced']);
    304496    }
    305497
     
    316508                update_post_meta( $post_id, 'wp_mapbox_gl_js_map_object', $_POST['wp_mapbox_gl_js_map_object']);
    317509            }
     510            if( isset( $_POST['wp_mapbox_gl_js_dataset_id_set'] ) && is_string($_POST['wp_mapbox_gl_js_dataset_id_set']) ) {
     511                update_post_meta( $post_id, 'wp_mapbox_gl_js_dataset_id', $_POST['wp_mapbox_gl_js_dataset_id_set']);
     512            }
     513            if( isset( $_POST['wp_mapbox_gl_js_hidden_in_post'] ) && $_POST['wp_mapbox_gl_js_hidden_in_post']=='checked' ) {
     514                update_post_meta( $post_id, 'wp_mapbox_gl_js_hidden_in_post', false);
     515            } else {
     516                update_post_meta( $post_id, 'wp_mapbox_gl_js_hidden_in_post', true);
     517            }
    318518    }
    319519
     
    327527            <div class="notice notice-success is-dismissible">
    328528              <img style="width: 50px;margin-top:10px;float:left;margin-right: 10px;" src="<?php echo plugins_url(); ?>/wp-mapbox-gl-js/admin/img/logo-Mapster.png" />
    329                     <h2>Nice work, you installed WP Mapbox GL JS Maps!</h2>
     529                    <h2>Nice work, you installed WP Mapbox GL JS!</h2>
    330530                    <p>Next, let's set up your Mapbox Access Token. Mapbox requires this in order to use their maps in a website. Go to <a href="<?php echo get_admin_url(); ?>/admin.php?page=wp-mapbox-gl-js-settings" target="_blank">the settings page</a> to enter yours.</p>
    331531                    <p>If you're not sure what an Access Token is, we have lots of help available.</p>
     
    335535    }
    336536
     537    /**
     538     * Add meta field we can set when uploading media
     539     *
     540     * @since    1.0.0
     541     */
     542    function wp_mapbox_gl_js_register_meta() {
     543        register_meta('post', 'wp_mapbox_gl_js_media', array(
     544          "type" => "string",
     545          "show_in_rest" => true,
     546      // 'single' => true
     547        ));
     548    }
     549
    337550}
  • wp-mapbox-gl-js/trunk/admin/css/wp-mapbox-gl-js-admin.css

    r2005792 r2368995  
     1.wp_mapbox_gl_js_staging {
     2  display: none;
     3}
    14.wp-mapbox-gl-js-advanced-options {
    25  display: none;
     
    1013  background: #eee;
    1114}
     15/* #wp_mapbox_gl_js_editor_content-html {
     16  display: none;
     17} */
     18.wp-mapbox-gl-js-custom-icon-creator canvas {
     19  /* float: right; */
     20  /* max-width: 90%; */
     21  /* min-width: 50px; */
     22}
     23.wp-mapbox-gl-js-custom-icon-creator #wp_mapbox_gl_js_canvas_img {
     24  display: none;
     25  height: 100px;
     26  width: auto;
     27}
     28.wp-mapbox-gl-js-custom-icon-creator, .wp-mapbox-gl-js-property-editor {
     29  transition: 1s;
     30  visibility: hidden;
     31    position: fixed;
     32    z-index: 2000;
     33    background:rgba(0,0,0,0.6);
     34}
     35/* end icon creator */
     36.wp-mapbox-gl-js-custom-icon-creator.now-active, .wp-mapbox-gl-js-property-editor.now-active {
     37  display: block;
     38  visibility: visible;
     39}
     40.wp-mapbox-gl-js-custom-icon-creator-container {
     41  width: 85%;
     42  margin-top: 100px;
     43  background: white;
     44  margin-left: 7.5%;
     45  display: flex;
     46  text-align: center;
     47}
     48.wp-mapbox-gl-js-property-editor-container {
     49  width: 85%;
     50  margin-top: 100px;
     51  background: white;
     52  margin-left: 7.5%;
     53  padding: 15px;
     54}
     55.wp-mapbox-gl-js-custom-icon-creator-editor {
     56  /* width: 30%;
     57  display: inline-block;
     58  vertical-align: top;
     59  margin-top: 100px;
     60  display: flex; */
     61}
     62.wp_mapbox_gl_js_actions {
     63  position: absolute;
     64  right: 0;
     65  bottom: 0;
     66  margin-right: 7.5%;
     67}
     68.wp-mapbox-gl-js-custom-icon-creator-icons {
     69  overflow-y: scroll;
     70  width: 80%;
     71}
     72.wp-mapbox-gl-js-custom-icon-creator-icons p {
     73  padding: 0;
     74  margin: 0;
     75}
     76.wp-mapbox-gl-js-custom-icon-creator-single-icon {
     77  width: 50px;
     78  padding: 10px;
     79  display: inline-block;
     80  text-align: center;
     81  transition: 0.5s;
     82}
     83.wp-mapbox-gl-js-custom-icon-creator-single-icon:hover {
     84  background: #efefef;
     85  cursor: pointer;
     86}
     87.wp-mapbox-gl-js-custom-icon-creator-single-icon img {
     88  width: 100%;
     89  height: auto;
     90  transition: 0.5s;
     91  margin-bottom: 0px;
     92  margin-top: 5px;
     93}
     94.wp-mapbox-gl-js-custom-icon-creator-single-icon:hover img {
     95  margin-bottom: 5px;
     96  margin-top: 0px;
     97}
     98
     99#wp_mapbox_gl_js_category_creator, #wp_mapbox_gl_js_layer_creator {
     100  display: none;
     101  margin-left: 20px;
     102}
     103#wp_mapbox_gl_js_category_creator > div, #wp_mapbox_gl_js_layer_creator > div {
     104  display: flex;
     105}
     106#category_filter_input {
     107  width: 60%;
     108}
     109.wp-mapbox-gl-js-custom-category-control, .wp-mapbox-gl-js-custom-layer-control {
     110  background: white;
     111  padding: 5px;
     112  box-shadow: 1px 1px 1px #333;
     113  width: 200px;
     114  min-height: 50px;
     115}
     116.wp-mapbox-gl-js-custom-category-control > div, .wp-mapbox-gl-js-custom-layer-control > div {
     117  margin-top: 5px;
     118}
     119.wp-mapbox-gl-js-custom-category-control h3, .wp-mapbox-gl-js-custom-layer-control h3 {
     120  margin: 0;
     121  padding: 0;
     122}
     123/* tooltips */
     124.wp_mapbox_gl_js_tooltip {
     125  background: grey;
     126  float: right;
     127  color: white;
     128  border-radius: 50%;
     129  padding: 1px 6px;
     130  cursor: pointer;
     131}
     132
     133/* dataset management */
     134.wp_mapbox_gl_js_dataset_error {
     135  margin-top: 10px;
     136}
     137.wp_mapbox_gl_js_features {
     138  display: none;
     139}
     140#wp-mapbox-gl-js-dataset-map {
     141  height: 200px;
     142  width: 100%;
     143}
     144#wp-mapbox-gl-js-to-dataset-update-updated, #wp-mapbox-gl-js-from-dataset-update-updated, #wp-mapbox-gl-js-from-dataset-update-updated-number, #wp-mapbox-gl-js-to-dataset-update-deleted {
     145  display: none;
     146  margin-top: 5px;
     147}
     148
     149#wp_mapbox_gl_js_directions_pre_fill_checkbox, #wp_mapbox_gl_js_directions_pre_fill_btn_container {
     150  display: flex;
     151  flex-direction: column;
     152  display: none;
     153  margin-left: 10px;
     154}
     155
     156.directions-btn {
     157  width: 150px;
     158}
     159
     160#select_origin_btn {
     161  margin-bottom: 5px;
     162}
     163
     164#wp_mapbox_gl_js_credentials {
     165  display: none;
     166}
     167
     168.wp-mapbox-gl-js-modal-options {
     169  background: white;
     170  padding: 10px;
     171}
  • wp-mapbox-gl-js/trunk/admin/js/wp-mapbox-gl-js-admin.js

    r2005792 r2368995  
    22    'use strict';
    33
     4    // Check is post title exists
     5    $(document).on('click','#publish',function(e) {
     6        if($('#title').val()==='') {
     7            e.preventDefault();
     8            alert('Please ensure you give the map post a title. It will not save properly otherwise.');
     9        }
     10    });
     11    $(document).on('click','#save-post',function(e) {
     12        if($('#title').val()==='') {
     13            e.preventDefault();
     14            alert('Please ensure you give the map post a title. It will not save properly otherwise.');
     15        }
     16    });
     17
     18    // Setting up allowing users to set feature, doing API call to get features
     19    $(document).on('change', '#wp_mapbox_gl_js_dataset_list', function(e) {
     20        e.preventDefault();
     21        $('#wp_mapbox_gl_js_dataset_id_set').val(e.target.value);
     22        if(e.target.value!=='') {
     23            $('.wp_mapbox_gl_js_features').show();
     24            $.ajax({
     25                url : "https://api.mapbox.com/datasets/v1/"+$('#wp_mapbox_gl_js_username').val()+"/"+e.target.value+"/features?access_token="+$('#wp_mapbox_gl_js_secret_token').val()
     26            }).done(function(data) {
     27                // opt for using "name" or "Name" if it exists; otherwise use the first property
     28                data.features.forEach(function(feature, index) {
     29                    var featureName = '';
     30                    if(featureName==='' && feature.properties.name) {
     31                        featureName = feature.properties.name;
     32                    }
     33                    if(featureName==='' && feature.properties.Name) {
     34                        featureName = feature.properties.Name;
     35                    }
     36                    if(featureName==='') {
     37                        for(var prop in feature.properties) {
     38                            featureName = feature.properties[prop];
     39                        }
     40                    }
     41                    if(featureName==='') {
     42                        featureName = 'Feature '+index;
     43                    }
     44                    $('#wp_mapbox_gl_js_feature_list').append('<option value="'+feature.id+'">'+featureName+'</option>');
     45                })
     46            });
     47        } else {
     48            $('.wp_mapbox_gl_js_features').hide();
     49        }
     50    });
     51
     52    // Toggling slider edit page
    453    $(document).on('click','.wp-mapbox-gl-js-advanced-options-button',function(e) {
    554        e.preventDefault();
     
    756    });
    857
     58    if($('#toggle_wp_mapbox_gl_js_credentials').length) {
     59        $(document).on('click','#toggle_wp_mapbox_gl_js_credentials',function(e) {
     60            e.preventDefault();
     61            $('#wp_mapbox_gl_js_credentials').slideToggle();
     62        })
     63    }
     64
     65    // Export functionality
     66    $(document).on('click','#wp-mapbox-gl-js-export-button',function(e) {
     67        function downloadTextFile(text, name) {
     68          const a = document.createElement('a');
     69          a.href = URL.createObjectURL( new Blob([text], { type:`text/${name.split(".").pop()}` }) );
     70          a.download = name;
     71          a.click();
     72        }
     73
     74        e.preventDefault();
     75        if($('#wp-mapbox-gl-js-category-export').val()!=='') {
     76            $.ajax({
     77                url : $('#wp-mapbox-gl-js-plugins').val()+"/wp-mapbox-gl-js/admin/partials/wp-mapbox-gl-js-print.php?gl_js_maps_category="+$('#wp-mapbox-gl-js-category-export').val(),
     78                method : 'GET',
     79                dataType: "json",
     80                contentType: "application/json;charset=utf-8"
     81            }).done(function(data) {
     82                downloadTextFile(JSON.stringify(data), $('#wp-mapbox-gl-js-category-export').val()+'.json');
     83            });
     84        }
     85    });
     86
     87    // Testing to see if access token is correct
    988    if(window.location.href.indexOf("wp-mapbox-gl-js-settings") > -1) {
    1089
    1190        try {
    12             var access_token = $('#mapbox_gl_js_access_token').val();
     91            var access_token = $('#wp_mapbox_gl_js_access_token').val();
    1392            mapboxgl.accessToken = access_token;
    1493            var map = new mapboxgl.Map({
     
    26105            $('.dashicons-no').show();
    27106        }
    28         // pk.eyJ1IjoidGVtcHJhbm92YSIsImEiOiJjaWd0c3M2MW4wOHI2dWNrbzZ5dWo1azVjIn0.x5sm8OjRxO9zO_uUmxYEqg
    29 
    30107    }
    31108
    32 })( jQuery );
     109    // Dataset map management
     110    $(document).on('click','#wp-mapbox-gl-js-to-dataset-add',function(e) {
     111        e.preventDefault();
     112        if(confirm('Are you sure you want to add these features in Mapbox? \n\n NOTE: it will take up to 10 minutes for Mapbox to show the changes in its dataset.')) {
     113            var updatedFeatures = [];
     114            var mapObject = JSON.parse($('#wp_mapbox_gl_js_map_object').val());
     115            mapObject.mapData.forEach(function(feature) {
     116                if(feature.id) {
     117                    if(feature.properties.marker_icon_anchor==='bottom'||feature.properties.marker_icon_anchor==='center') {
     118                        delete feature.properties.marker_icon_anchor;
     119                    }
     120                    if(feature.properties.popup_open) {
     121                        delete feature.properties.popup_open;
     122                    }
     123                    if(feature.properties.marker_icon_url.indexOf('black_default.png')>-1) {
     124                        delete feature.properties.marker_icon_url;
     125                    }
     126                    if(feature.properties.marker_title==='Line'||feature.properties.marker_title==='Fill'||feature.properties.marker_title==='Marker') {
     127                        delete feature.properties.marker_title;
     128                    }
     129                    if(feature.properties.color==='#333') {
     130                        delete feature.properties.color;
     131                    }
     132                    if(feature.properties.description==='Description') {
     133                        delete feature.properties.description;
     134                    }
     135                    $.ajax({
     136                        headers : { "Content-Type": "application/json"},
     137                        url : "https://api.mapbox.com/datasets/v1/"+$('#wp_mapbox_gl_js_username').val()+"/"+$('#wp_mapbox_gl_js_dataset_list').val()+"/features/"+feature.id+"?access_token="+$('#wp_mapbox_gl_js_secret_token').val(),
     138                        method : "PUT",
     139                        data : JSON.stringify(feature)
     140                    }).done(function(data) {
     141                        updatedFeatures.push(data);
     142                        if(updatedFeatures.length===mapObject.mapData.length) {
     143                            $('#wp-mapbox-gl-js-from-dataset-update-updated').fadeIn();
     144                            setTimeout(function() {
     145                                $('#publish').trigger('click');
     146                            },1000);
     147                        }
     148                    });
     149                }
     150            });
     151        }
     152    });
     153
     154    if($('#wp_mapbox_gl_js_access_token').length && $('#wp-mapbox-gl-js-dataset-map').length) {
     155        var access_token = $('#wp_mapbox_gl_js_access_token').val();
     156        mapboxgl.accessToken = access_token;
     157        var map = new mapboxgl.Map({
     158            style : 'mapbox://styles/mapbox/light-v9',
     159            container : 'wp-mapbox-gl-js-dataset-map'
     160        });
     161
     162        // Load the features listed in the dataset
     163        map.on('load',function() {
     164            var features = [];
     165            var featureIDs = JSON.parse($('#wp_mapbox_gl_js_features').val());
     166            var bounds = new mapboxgl.LngLatBounds();
     167            var count = 0;
     168            featureIDs.forEach(function(feature, index) {
     169                $.ajax({
     170                    url : "https://api.mapbox.com/datasets/v1/"+$('#wp_mapbox_gl_js_username').val()+"/"+$('#wp_mapbox_gl_js_dataset').val()+"/features/"+feature+"?access_token="+$('#wp_mapbox_gl_js_secret_token').val()
     171                }).done(function(data) {
     172                    // features.push(data);
     173                    count += 1;
     174                    if(data.geometry.type==="Point") {
     175                    bounds.extend(data.geometry.coordinates);
     176                    }
     177                    if(data.geometry.type==="LineString") {
     178                        data.geometry.coordinates.forEach(function(coord) {
     179                        bounds.extend(coord);
     180                        })
     181                    }
     182                    if(data.geometry.type==="Polygon") {
     183                        data.geometry.coordinates[0].forEach(function(coord) {
     184                        bounds.extend(coord);
     185                        })
     186                    }
     187                    map.addSource('imported-'+index, {
     188                        type : 'geojson',
     189                        data : {
     190                            type : "FeatureCollection",
     191                            features : [data]
     192                        }
     193                    })
     194                    if(data.geometry.type==='Point') {
     195                        map.addLayer({
     196                            id : 'imported-'+index,
     197                            source : 'imported-'+index,
     198                        type: "circle"
     199                        });
     200                    }
     201                    if(data.geometry.type==='LineString'||data.geometry.type==='MultiLineString') {
     202                        map.addLayer({
     203                            id : 'imported-'+index,
     204                            source : 'imported-'+index,
     205                        type: "line"
     206                        });
     207                    }
     208                    if(data.geometry.type==='Polygon'||data.geometry.type==='MultiPolygon') {
     209                        map.addLayer({
     210                            id : 'imported-'+index,
     211                            source : 'imported-'+index,
     212                        type: "fill"
     213                        });
     214                    }
     215                    map.fitBounds(bounds);
     216                });
     217            });
     218        });
     219
     220        $(document).on('click','#wp-mapbox-gl-js-to-dataset-delete',function(e) {
     221            e.preventDefault();
     222            if(confirm('Are you sure you want to completely delete these features in Mapbox? This cannot be reversed. \n\n NOTE: it will take up to 10 minutes for Mapbox to show the changes in its dataset.')) {
     223                var updatedFeatures = [];
     224                var mapObject = JSON.parse($('#wp_mapbox_gl_js_map_object').val());
     225                mapObject.mapData.forEach(function(feature) {
     226                    if(feature.id) {
     227                        $.ajax({
     228                            headers : { "Content-Type": "application/json"},
     229                            url : "https://api.mapbox.com/datasets/v1/"+$('#wp_mapbox_gl_js_username').val()+"/"+$('#wp_mapbox_gl_js_dataset').val()+"/features/"+feature.id+"?access_token="+$('#wp_mapbox_gl_js_secret_token').val(),
     230                            method : "DELETE"
     231                        }).done(function(data) {
     232                            updatedFeatures.push(data);
     233                            if(updatedFeatures.length===mapObject.mapData.length) {
     234                                $('#wp-mapbox-gl-js-to-dataset-update-deleted').fadeIn();
     235                            }
     236                        });
     237                    }
     238                });
     239            }
     240        });
     241
     242        $(document).on('click','#wp-mapbox-gl-js-to-dataset-update',function(e) {
     243            e.preventDefault();
     244            if(confirm('Are you sure you want to send the features from this WP GL JS post to Mapbox? This is not easily reversed. \n\n NOTE: it will take up to 10 minutes for Mapbox to show the changes in its dataset.')) {
     245                var updatedFeatures = [];
     246                var mapObject = JSON.parse($('#wp_mapbox_gl_js_map_object').val());
     247                mapObject.mapData.forEach(function(feature) {
     248                    if(feature.id) {
     249                        if(feature.properties.marker_icon_anchor==='bottom'||feature.properties.marker_icon_anchor==='center') {
     250                            delete feature.properties.marker_icon_anchor;
     251                        }
     252                        if(feature.properties.popup_open) {
     253                            delete feature.properties.popup_open;
     254                        }
     255                        if(feature.properties.marker_icon_url.indexOf('black_default.png')>-1) {
     256                            delete feature.properties.marker_icon_url;
     257                        }
     258                        if(feature.properties.marker_title==='Line'||feature.properties.marker_title==='Fill'||feature.properties.marker_title==='Marker') {
     259                            delete feature.properties.marker_title;
     260                        }
     261                        if(feature.properties.color==='#333') {
     262                            delete feature.properties.color;
     263                        }
     264                        if(feature.properties.description==='Description') {
     265                            delete feature.properties.description;
     266                        }
     267                        $.ajax({
     268                            headers : { "Content-Type": "application/json"},
     269                            url : "https://api.mapbox.com/datasets/v1/"+$('#wp_mapbox_gl_js_username').val()+"/"+$('#wp_mapbox_gl_js_dataset').val()+"/features/"+feature.id+"?access_token="+$('#wp_mapbox_gl_js_secret_token').val(),
     270                            method : "PUT",
     271                            data : JSON.stringify(feature)
     272                        }).done(function(data) {
     273                            updatedFeatures.push(data);
     274                            if(updatedFeatures.length===mapObject.mapData.length) {
     275                                $('#wp-mapbox-gl-js-to-dataset-update-updated').fadeIn();
     276                            }
     277                        });
     278                    }
     279                });
     280            }
     281        });
     282
     283        $(document).on('click','#wp-mapbox-gl-js-from-dataset-update',function(e) {
     284            e.preventDefault();
     285            if(confirm('Are you sure you want to overwrite the features in this WP GL JS post using the latest data in your Mapbox dataset?')) {
     286                var mapObject = JSON.parse($('#wp_mapbox_gl_js_map_object').val());
     287                var currentNumber = parseInt($('#wp-mapbox-gl-js-from-dataset-update-updated-number').text());
     288                var numberToMatch = 0;
     289                mapObject.mapData.forEach(function(feature) {
     290                    if(feature.id) {
     291                        numberToMatch += 1;
     292                        $.ajax({
     293                            url : "https://api.mapbox.com/datasets/v1/"+$('#wp_mapbox_gl_js_username').val()+"/"+$('#wp_mapbox_gl_js_dataset').val()+"/features/"+feature.id+"?access_token="+$('#wp_mapbox_gl_js_secret_token').val(),
     294                        }).done(function(data) {
     295                            mapObject.mapData.forEach(function(thisMapData) {
     296                                if(thisMapData.id===data.id) {
     297                                    thisMapData.geometry = data.geometry;
     298                                    for (var property in data.properties) {
     299                                        thisMapData.properties[property] = data.properties[property];
     300                                    }
     301                                    currentNumber += 1;
     302                                    $('#wp-mapbox-gl-js-from-dataset-update-updated').fadeIn();
     303                                    $('#wp-mapbox-gl-js-from-dataset-update-updated-number').fadeIn();
     304                                    $('#wp-mapbox-gl-js-from-dataset-update-updated-number').text(currentNumber);
     305                                }
     306                            });
     307                            if(currentNumber===numberToMatch) {
     308                                setTimeout(function() {
     309                                    $('#wp_mapbox_gl_js_map_object').val(JSON.stringify(mapObject));
     310                                    $('#publish').trigger('click');
     311                                },1000);
     312                            }
     313                        });
     314                    }
     315                })
     316            }
     317        });
     318    }
     319
     320})(jQuery);
  • wp-mapbox-gl-js/trunk/admin/wp-mapbox-gl-js-settings.php

    r2005792 r2368995  
    2121<div class="wrap">
    2222
    23     <h1>WP Mapbox GL JS Maps</h1>
     23    <h1>WP Mapbox GL JS</h1>
    2424
    2525    <p>Enter your <a href="https://www.mapbox.com/account/access-tokens" target="_blank">access token</a> here.
    26     <p><a href="https://www.mapster.me/wp-mapbox-gl-js/" target="_blank">Visit the documentation</a> to learn more about using the WP Mapbox GL JS shortcode. More features coming soon!</p>
     26    <p><a href="http://www.mapster.me/wp-mapbox-gl-js/wp-mapbox-gl-js-shortcode-documentation/" target="_blank">Visit the documentation</a> to learn more about using the WP Mapbox GL JS shortcode. More features coming soon!</p>
    2727
    2828  <form action="" method="POST">
  • wp-mapbox-gl-js/trunk/admin/wp-mapmaker/public/css/style.css

    r2005792 r2368995  
    4343.wp-mapbox-gl-js-tabs-left {
    4444    width: 20%;
     45}
     46.wp-mapbox-gl-js-tabs-left ul {
     47    margin-top: 0px;
    4548}
    4649.wp-mapbox-gl-js-tabs-left ul li {
     
    204207    margin-top: 10px;
    205208}
     209.wp-mapbox-gl-js-dropzone > div {
     210    padding: 15px;
     211    font-size: 12px;
     212    width: auto !important;
     213    height: auto !important;
     214}
    206215
    207216.wp-mapbox-gl-js-custom-draw-controls {
     
    213222    margin-bottom: 15px;
    214223    width: 90px;
    215     margin-left: -60px;
     224    margin-left: -45px;
     225    /* width: 150px;
     226    margin-left: -75px; */
    216227    margin-top: 340px;
    217228}
     
    300311}
    301312
     313#extrusion-input-container {
     314    display: flex;
     315}
     316
     317#extrusion-input-container label {
     318    display: flex;
     319    flex-direction: column;
     320    margin-right: 5px;
     321    width: 100px;
     322}
     323
     324#controls-container {
     325    display: flex;
     326}
     327
     328#category-filter-container {
     329    margin-top: auto;
     330    max-width: 220px;
     331    display: flex;
     332    height: 28px;
     333}
     334
     335#category-filter-container-btn {
     336    margin-left: 5px;
     337    width: 200px;
     338}
     339
     340#category_filter_input_form_container {
     341    margin-top: 5px;
     342}
     343
     344#category_filter_input_form_container #category_filter_input_submit {
     345    margin-top: 5px;
     346}
     347
    302348@keyframes fade-in-out {
    303349    0% {
  • wp-mapbox-gl-js/trunk/includes/class-wp-mapbox-gl-js.php

    r2005792 r2368995  
    160160        $this->loader->add_action( 'add_meta_boxes', $plugin_admin, 'add_wp_mapbox_gl_js_meta_box' );
    161161        $this->loader->add_action( 'init', $plugin_admin, 'create_gl_js_maps' );
     162        $this->loader->add_action( 'init', $plugin_admin, 'wp_mapbox_gl_js_register_meta' );
    162163        $this->loader->add_action( 'edit_form_after_title', $plugin_admin, 'move_above_editor' );
    163164        $this->loader->add_action( 'save_post', $plugin_admin, 'wp_mapbox_gl_js_map_save' );
    164165        $this->loader->add_action( 'admin_notices', $plugin_admin, 'wp_mapbox_gl_js_admin_notice' );
    165        
     166
    166167    }
    167168
     
    179180        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
    180181    $this->loader->add_action( 'init', $plugin_public, 'register_shortcodes' );
     182        $this->loader->add_filter( 'the_content', $plugin_public, 'wp_mapbox_gl_js_add_map_to_content' );
    181183
    182184    }
  • wp-mapbox-gl-js/trunk/public/class-wp-mapbox-gl-js-public.php

    r2356757 r2368995  
    7676    public function enqueue_scripts() {
    7777
    78             wp_enqueue_script('mapbox_gl_js', 'https://api.mapbox.com/mapbox-gl-js/v1.11.1/mapbox-gl.js', array('jquery'), '', false);
    79             wp_enqueue_script('mapbox_gl_geocoder_js', 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v2.2.0/mapbox-gl-geocoder.min.js', array('mapbox_gl_js'), '', false);
    80             wp_enqueue_script('mapbox_gl_directions_js', 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-directions/v3.1.1/mapbox-gl-directions.js', array('mapbox_gl_geocoder_js'), '', false);
    81             wp_enqueue_script( $this->wp_mapbox_gl_js, plugin_dir_url( __FILE__ ) . 'js/wp-mapbox-gl-js-public.js', array( 'mapbox_gl_directions_js' ), mt_rand(10,1000), false );
    82 
    83     }
    84 
     78        wp_enqueue_script('mapbox_gl_js', 'https://api.mapbox.com/mapbox-gl-js/v1.11.1/mapbox-gl.js', array('jquery'), '', false);
     79        wp_enqueue_script('mapbox_gl_geocoder_js', 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v2.2.0/mapbox-gl-geocoder.min.js', array('mapbox_gl_js'), '', false);
     80        wp_enqueue_script('mapbox_gl_directions_js', 'https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-directions/v3.1.1/mapbox-gl-directions.js', array('mapbox_gl_geocoder_js'), '', false);
     81        wp_enqueue_script( $this->wp_mapbox_gl_js, plugin_dir_url( __FILE__ ) . 'js/wp-mapbox-gl-js-public.js', array( 'mapbox_gl_directions_js' ), mt_rand(10,1000), false );
     82
     83    }
    8584
    8685    /**
     
    101100            'zoom' => '',
    102101            'pitch' => '',
    103             'bearing' => ''
     102            'bearing' => '',
     103            'scrollZoom' => '',
     104            'mapCategories' => '',
     105            'mapLayersFilter' => '',
    104106        ), $atts, 'wp_mapbox_gl_js' );
    105107
     
    118120            // $map_post = get_post($atts['map_id']);
    119121
     122
    120123            $map_object = json_decode(get_post_meta( $atts['map_id'], 'wp_mapbox_gl_js_map_object', true ));
     124
    121125            // var_dump($map_object);
    122126            $zoom = ($atts['zoom']=='' ? $map_object->zoom : esc_attr($atts['zoom']));
    123127            $pitch = ($atts['pitch']=='' ? $map_object->pitch : esc_attr($atts['pitch']));
    124128            $bearing = ($atts['bearing']=='' ? $map_object->bearing : esc_attr($atts['bearing']));
     129            if(isset($map_object->scrollZoom)) {
     130                $scrollZoom = ($atts['scrollZoom']=='' ? $map_object->scrollZoom : esc_attr($atts['scrollZoom']));
     131            }
     132            if(isset($map_object->controls->scrollZoom)) {
     133                $scrollZoom = ($atts['scrollZoom']=='' ? $map_object->controls->scrollZoom : esc_attr($atts['scrollZoom']));
     134            }
     135            $mapCategories = ($atts['mapCategories']=='' ? $map_object->mapCategories : esc_attr($atts['mapCategories']));
     136            $mapOrigin = ($atts['mapOrigin']=='' ? $map_object->preFillDirections->origin : esc_attr($atts['mapOrigin']));
     137            $mapDestination = ($atts['mapDestination']=='' ? $map_object->preFillDirections->destination : esc_attr($atts['mapDestination']));
     138            $mapLayersFilter = ($atts['mapLayersFilter']=='' ? $map_object->mapLayersFilter : esc_attr($atts['mapLayersFilter']));
    125139            $center = ($atts['center']=='' ? implode(',',$map_object->center) : esc_attr($atts['center']));
    126140            $style = $map_object->style;
     
    134148                    data-center='<?php echo $center; ?>'
    135149                    data-zoom='<?php echo $zoom; ?>'
     150                    data-scroll-zoom='<?php echo json_encode($scrollZoom); ?>'
    136151                    data-pitch='<?php echo $pitch; ?>'
    137152                    data-bearing='<?php echo $bearing; ?>'
    138153                    data-style='<?php echo $style; ?>'
    139154                    data-controls='<?php echo json_encode($map_object->controls); ?>'
    140                     data-mapdata='<?php echo json_encode($map_object->mapData); ?>'
     155                    data-mapdata='<?php echo esc_html(json_encode($map_object->mapData)); ?>'
    141156                    data-token='<?php echo get_option( 'mapbox_gl_js_access_token', true); ?>'
     157                    data-map-categories='<?php echo json_encode($mapCategories); ?>'
     158                    data-map-origin='<?php echo json_encode($mapOrigin); ?>'
     159                    data-map-destination='<?php echo json_encode($mapDestination); ?>'
     160                    data-map-layers-filter='<?php echo json_encode($mapLayersFilter); ?>'
    142161                    class="wp-mapbox-gl-js-map" ></div>
    143162            <?php
     
    174193                    data-center='<?php echo esc_attr($atts['center']); ?>'
    175194                    data-zoom='<?php echo esc_attr($atts['zoom']); ?>'
     195                    data-scrollZoom='<?php echo esc_attr($atts['scrollZoom']); ?>'
    176196                    data-pitch='<?php echo esc_attr($atts['pitch']); ?>'
    177197                    data-bearing='<?php echo esc_attr($atts['bearing']); ?>'
    178198                    data-style='<?php echo esc_attr($first_style); ?>'
    179199                    data-token='<?php echo get_option( 'mapbox_gl_js_access_token', true); ?>'
     200                    data-map-categories='<?php echo json_encode($mapCategories); ?>'
     201                    data-map-layers-filter='<?php echo json_encode($mapLayersFilter); ?>'
    180202                    class="wp-mapbox-gl-js-map" ></div>
    181203            </div>
     
    198220    }
    199221
     222    /**
     223        * Add shortcode to map page
     224        *
     225        * @since 1.0.0
     226        *
     227    */
     228    function wp_mapbox_gl_js_add_map_to_content( $content ) {
     229        if ( is_singular('gl_js_maps') && get_post_meta( get_the_ID(), 'wp_mapbox_gl_js_hidden_in_post', true) ) {
     230            return $content;
     231        } elseif (is_singular('gl_js_maps')) {
     232        $custom_content = do_shortcode('[wp_mapbox_gl_js map_id="'.get_the_ID().'"]');
     233            $custom_content .= '<br />';
     234        $custom_content .= $content;
     235        return $custom_content;
     236        } else {
     237            return $content;
     238        }
     239    }
     240
    200241
    201242}
  • wp-mapbox-gl-js/trunk/public/css/wp-mapbox-gl-js-public.css

    r2005792 r2368995  
    66    font-family: 'Open Sans', sans-serif;
    77}
     8
     9#wp_mapbox_gl_js_category_creator, #wp_mapbox_gl_js_layer_creator {
     10    display: none;
     11    margin-left: 20px;
     12}
     13
     14#wp_mapbox_gl_js_category_creator > div, #wp_mapbox_gl_js_layer_creator > div {
     15    display: flex;
     16}
     17
     18#category_filter_input {
     19    width: 60%;
     20}
     21
     22.wp-mapbox-gl-js-custom-category-control, .wp-mapbox-gl-js-custom-layer-control {
     23    background: white;
     24    padding: 5px;
     25    box-shadow: 1px 1px 1px #333;
     26    width: 200px;
     27    min-height: 50px;
     28    font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
     29}
     30
     31.wp-mapbox-gl-js-custom-category-control > div, .wp-mapbox-gl-js-custom-layer-control > div {
     32    margin-top: 5px;
     33}
     34.wp-mapbox-gl-js-custom-category-control input, .wp-mapbox-gl-js-custom-layer-control input {
     35    margin-right: 5px;
     36}
     37
     38.wp-mapbox-gl-js-custom-category-control h3, .wp-mapbox-gl-js-custom-layer-control h3 {
     39    font-weight: 600;
     40    font-size: 1.3em;
     41    margin: 0;
     42    padding: 0;
     43}
     44
     45.wp-mapbox-gl-js-custom-category-control div div, .wp-mapbox-gl-js-custom-layer-control div div {
     46    display: flex;
     47}
     48
     49/* .wp_mapbox_gl_js_frontend_popup {
     50    maxWidth: 66%;
     51} */
     52
     53
     54.wp-mapbox-gl-js-location-sidebar p {
     55  background: #fff;
     56  border-bottom: 1px solid #eee;
     57  min-height: 60px;
     58  line-height: 60px;
     59  margin-bottom: 0px;
     60  padding: 0 10px;
     61  background-color: #00853e;
     62  color: #fff;
     63}
     64.wp-mapbox-gl-js-location-sidebar li {
     65  display: block;
     66  color: #00853e;
     67  border-bottom: 1px solid #eee;
     68  padding: 10px;
     69  font-weight: 700;
     70  cursor: pointer;
     71}
     72.wp-mapbox-gl-js-location-sidebar li:hover {
     73   color: #8cc63f;
     74 }
  • wp-mapbox-gl-js/trunk/public/js/wp-mapbox-gl-js-public.js

    r2005792 r2368995  
    99      $('.wp-mapbox-gl-js-map').each(function() {
    1010         var data = $(this).data();
    11          // console.log(data)
     11         var map = false;
     12        //  console.log(data)
     13        //  window._data = data;
    1214         var mapStyle = {
    1315           'container' : $(this).attr('id'),
     
    2426           }
    2527         });
    26          var map = new mapboxgl.Map(mapStyle);
     28         // Change size of the div if store locator turned on
     29         if(data.controls.locationSidebar) {
     30           var originalWidth = $(this).width();
     31           var newDivWrap = document.createElement('div');
     32           $(this).attr('style', function(i, style) {
     33              return style && style.replace(/width[^;]+;?/g, '');
     34           });
     35           $(this).css('width',originalWidth*0.8);
     36           $(this).css('float','right');
     37           $(this).wrap(newDivWrap);
     38           var locationSidebarDiv = document.createElement('div');
     39           locationSidebarDiv.className = 'wp-mapbox-gl-js-location-sidebar';
     40           locationSidebarDiv.style.width = originalWidth*0.19+'px';
     41           locationSidebarDiv.style.height = $(this).height()+'px';
     42           locationSidebarDiv.style.float = 'left';
     43           $(locationSidebarDiv).append('<p><strong>Locations</strong></p>');
     44           var thisLocationUL = document.createElement('ul');
     45           data.mapdata.forEach(function(feature, index) {
     46             var bounds = getBoundingBox(feature);
     47             var thisLocationLI = document.createElement('li');
     48             thisLocationLI.setAttribute('data-bounds', JSON.stringify(bounds));
     49             thisLocationLI.textContent = feature.properties.marker_title;
     50             thisLocationLI.addEventListener('click', function() {
     51               if($(this).data().bounds[0][0]===$(this).data().bounds[1][0]&$(this).data().bounds[0][1]===$(this).data().bounds[1][1]) {
     52                 map.flyTo({
     53                   center : $(this).data().bounds[0],
     54                   zoom : 13
     55                 });
     56               } else {
     57                 map.fitBounds($(this).data().bounds)
     58               }
     59             });
     60             thisLocationUL.appendChild(thisLocationLI);
     61           });
     62           $(locationSidebarDiv).append(thisLocationUL);
     63           $(this).parent().prepend(locationSidebarDiv)
     64         }
     65
     66         map = new mapboxgl.Map(mapStyle);
    2767         allMaps[$(this).attr('id')] = map;
    2868
    2969         map.on('load',function() {
    30            // console.log(data.controls)
     70
     71          // console.log('DATA.CONTROLS', data.controls)
    3172            // Add controls
    3273           if(data.controls.navigation) {
     
    5293           }
    5394           if(data.controls.directions) {
    54              map.addControl(new MapboxDirections({
    55                 accessToken: mapboxgl.accessToken
    56              }), 'top-left');
     95             var mapboxDirections = new MapboxDirections({
     96              accessToken: mapboxgl.accessToken,
     97              interactive: false
     98             });
     99
     100             window['_mapboxDirections'] = mapboxDirections;
     101             map.addControl(mapboxDirections, 'top-left');
     102           }
     103          if(data.controls.directions && data.controls.preFillInput && window['_mapboxDirections']) {
     104            window['_mapboxDirections'].setOrigin(data.mapOrigin);
     105            window['_mapboxDirections'].setDestination(data.mapDestination);
     106          }
     107
     108           // scrollZoom setting
     109           if (data.scrollZoom === false) {
     110             map.scrollZoom.disable();
     111           } else if (data.scrollZoom === true) {
     112             map.scrollZoom.enable();
     113
     114           }
     115
     116           if (data.controls.geolocaterControl) {
     117            const geolocaterControl = new mapboxgl.GeolocateControl({
     118              positionOptions: { enableHighAccuracy: true },
     119              trackUserLocation: true
     120            });
     121            map.addControl(geolocaterControl);
     122           }
     123
     124          //  Layer filter
     125          if (data.controls.layerFilter) {
     126            const layerControl = new CustomLayerControl({
     127             layers : data.mapLayersFilter
     128            });
     129            map.addControl(layerControl, 'top-left');
     130          }
     131
     132          //  Category filter
     133          if (data.controls.categoryFilter) {
     134             const categoryControl = new CustomCategoryControl({
     135              categories : data.mapCategories,
     136              mapData : data.mapdata
     137             });
     138             map.addControl(categoryControl, 'top-left');
    57139           }
    58140
    59141           // Map data add
    60            data.mapdata.forEach(function(feature,index) {
     142           data.mapdata.forEach(function(feature, index) {
    61143             var featureCollection = {
    62144               "type" : "FeatureCollection",
     
    65147             // If only a marker icon or color has changed
    66148             if(typeof map.getSource(feature.id)==='undefined') {
     149               if(typeof feature.properties.opacity === 'undefined') {
     150                 feature.properties.opacity = 0.4;
     151               }
    67152               map.addSource(feature.id, {
    68153                 "type": "geojson",
     
    72157                 // Add the icon image, then add layer
    73158                 if(!map.hasImage(feature.properties.marker_icon_url)) {
    74                    map.loadImage($('#wp_mapbox_gl_js_plugin_url').val()+'/wp-mapbox-gl-js/admin/wp-mapmaker/public/img/'+feature.properties.marker_icon_url, function(error, image) {
    75                      if (error) throw error;
    76                      map.addImage(feature.properties.marker_icon_url, image);
    77                      // default_marker.svg
     159                   var canvas = document.createElement('canvas');
     160                   var ctx = canvas.getContext('2d');
     161                   var img  = document.createElement('img');
     162                   img.onload = function() {
     163                     var sizingOfImage = feature.properties.marker_icon_url.split('-wp_mapbox_gl_js_sizing-')[1];
     164                     var widthHeight = sizingOfImage ? sizingOfImage.split('-') : [100,100];
     165                     canvas.width  = widthHeight[0];
     166                     canvas.height = widthHeight[1];
     167                     ctx.drawImage(img, 0, 0, widthHeight[0], widthHeight[1]);
     168                     map.addImage(feature.properties.marker_icon_url, ctx.getImageData(0, 0, widthHeight[0], widthHeight[1]) );
     169                     var markerOverlap = true;
     170                     if(typeof data.controls.markerNoDisappear !== 'undefined') {
     171                       markerOverlap = data.controls.markerNoDisappear;
     172                     }
    78173                     var lineLayer = map.addLayer({
    79174                       'id': feature.id,
     
    82177                       'layout': {
    83178                         'icon-image': feature.properties.marker_icon_url,
    84                          'icon-anchor' : 'bottom',
    85                          'icon-size' : 0.2
     179                         'icon-anchor' : feature.properties.marker_icon_anchor,
     180                         'icon-size' : 0.2,
     181                         'icon-allow-overlap' : markerOverlap
    86182                       }
    87183                     })
    88184                     if(feature.properties.popup_open) {
    89185                       var popup = new mapboxgl.Popup({
    90                          offset : 20
    91                        });
     186                         offset : 20,
     187                         className: 'wp_mapbox_gl_js_frontend_popup'
     188                      });
    92189                       popup.setLngLat({lat: feature.geometry.coordinates[1], lng: feature.geometry.coordinates[0]})
    93190                         .setHTML(
     
    96193                           '</div>'
    97194                         ).addTo(map);
    98                      }
    99                    });
     195
     196                        popup._container.style.maxWidth = "66%";
     197                      }
     198                   };
     199                   img.src = feature.properties.marker_icon_url.split('-wp_mapbox_gl_js_sizing-')[0];
    100200                 } else {
    101201                   var lineLayer = map.addLayer({
     
    113213                   map.on('click',feature.id,function(e) {
    114214                     var popup = new mapboxgl.Popup({
    115                        offset : 20
    116                      })
     215                      offset : 20,
     216                      className: 'wp_mapbox_gl_js_frontend_popup'
     217                    })
    117218                     popup.setLngLat({lat: feature.geometry.coordinates[1], lng: feature.geometry.coordinates[0]})
    118219                       .setHTML(
     
    121222                         '</div>'
    122223                       ).addTo(map);
     224
     225                       popup._container.style.maxWidth = "66%";
     226                      })
     227                 }
     228               } else if(feature.geometry.type==='Polygon') {
     229                 if(feature.fillType) {
     230                   var lineLayer = map.addLayer({
     231                     'id': feature.id,
     232                     'type': 'fill-extrusion',
     233                     'source' : feature.id,
     234                     'paint': {
     235                       'fill-extrusion-color' : feature.properties.color,
     236                       'fill-extrusion-opacity' : feature.properties.opacity,
     237                       'fill-extrusion-height' : feature.properties.height,
     238                       'fill-extrusion-base' : feature.properties.base_height
     239                     }
     240                   })
     241                 } else {
     242                   var lineLayer = map.addLayer({
     243                     'id': feature.id,
     244                     'type': 'fill',
     245                     'source' : feature.id,
     246                     'paint': {
     247                       'fill-color' : feature.properties.color,
     248                       'fill-opacity' : feature.properties.opacity
     249                     }
    123250                   })
    124251                 }
    125                } else if(feature.geometry.type==='Polygon') {
    126                  var lineLayer = map.addLayer({
    127                    'id': feature.id,
    128                    'type': 'fill',
    129                    'source' : feature.id,
    130                    'paint': {
    131                      'fill-color' : feature.properties.color,
    132                      'fill-opacity' : 0.4
    133                    }
    134                  })
    135252               } else if(feature.geometry.type==='LineString') {
    136253                 var lineLayer = map.addLayer({
     
    151268        allMaps[$(this).data('map-id')].setStyle($(this).attr('id'));
    152269      });
    153 
     270      $(document).on('click','#wp_mapbox_gl_js_set_directions',function(e) {
     271        e.preventDefault();
     272        var coords = $(this).data('lngLat');
     273        window._mapboxDirections.setDestination(coords);
     274      });
     275    }
     276
     277    // Custom Layer Control Class
     278    class CustomLayerControl {
     279      // Commented b/c it was throwing errors
     280      // _options: {
     281      //   layers: []
     282      // };
     283
     284      constructor(options) {
     285        const _options = { layers: [] };
     286
     287        this._options = Object.assign({}, _options, options)
     288      }
     289
     290      addHeading() {
     291        var heading = document.createElement('h3');
     292        heading.appendChild(document.createTextNode('Layer Filter'));
     293        return heading;
     294      }
     295
     296      onAdd(map){
     297        this.map = map;
     298        this.container = document.createElement('div');
     299        this.container.className = 'mapboxgl-ctrl wp-mapbox-gl-js-custom-layer-control';
     300        this.container.appendChild(this.addHeading());
     301
     302        var thisCategoryDiv = this._addLayers(this._options.layers);
     303        this.container.appendChild(thisCategoryDiv);
     304        return this.container;
     305      }
     306
     307      onRemove(){
     308        this.container.parentNode.removeChild(this.container);
     309        this.map = undefined;
     310      }
     311
     312      _addLayers(layers) {
     313        const el = window.document.createElement('div')
     314        layers.forEach(function(layer) {
     315          const innerElement = window.document.createElement('div')
     316          const input = window.document.createElement('input')
     317          input.type = "checkbox";
     318          input.checked = "checked";
     319          input.name = layer;
     320          input.value = layer;
     321          input.id = 'wp-mapbox-gl-js-'+layer;
     322          input.addEventListener('change',(e)=>{
     323            if(e.target.checked) {
     324              this.map.setLayoutProperty(layer,'visibility','visible');
     325            } else {
     326              this.map.setLayoutProperty(layer,'visibility','none');
     327            }
     328          });
     329          innerElement.appendChild(input)
     330
     331          var label = document.createElement('label')
     332          label.htmlFor = 'wp-mapbox-gl-js-'+layer;;
     333          label.appendChild(document.createTextNode(layer));
     334          innerElement.appendChild(label)
     335
     336          el.appendChild(innerElement);
     337        }.bind(this));
     338        return el;
     339      }
     340
     341      updateLayers(layers) {
     342        this.container.innerHTML = '';
     343        this.container.appendChild(this.addHeading());
     344        var thisLayerDiv = this._addLayers(layers);
     345        this.container.appendChild(thisLayerDiv);
     346      }
     347
     348    }
     349
     350    // Custom Category Control Class
     351    class CustomCategoryControl {
     352      // _options: {
     353      //   categories: [],
     354      //   mapData : []
     355      // };
     356
     357      constructor(options) {
     358        const _options = { categories: [], mapData : [] };
     359
     360        this._options = Object.assign({}, _options, options);
     361      }
     362
     363      addHeading() {
     364        var heading = document.createElement('h3');
     365        heading.appendChild(document.createTextNode('Filter'));
     366        return heading;
     367      }
     368
     369      onAdd(map){
     370        this.map = map;
     371        this.container = document.createElement('div');
     372        this.container.className = 'mapboxgl-ctrl wp-mapbox-gl-js-custom-category-control';
     373        this.container.appendChild(this.addHeading());
     374
     375        var thisCategoryDiv = this._addCategories(this._options.categories);
     376        this.container.appendChild(thisCategoryDiv);
     377        return this.container;
     378      }
     379
     380      onRemove(){
     381        this.container.parentNode.removeChild(this.container);
     382        this.map = undefined;
     383      }
     384
     385      _addCategories(categories) {
     386        const el = window.document.createElement('div')
     387        categories.forEach(function(category) {
     388          const innerElement = window.document.createElement('div')
     389          const input = window.document.createElement('input')
     390          input.type = "checkbox";
     391          input.checked = "checked";
     392          input.name = category;
     393          input.value = category;
     394          input.id = 'wp-mapbox-gl-js-'+category;
     395          input.addEventListener('change',(e)=>{
     396            if(e.target.checked) {
     397              this._options.mapData.forEach(function(feature) {
     398                if(feature.properties.category===e.target.value) {
     399                  this.map.setLayoutProperty(feature.id,'visibility','visible');
     400                }
     401              }.bind(this));
     402            } else {
     403              this._options.mapData.forEach(function(feature) {
     404                if(feature.properties.category===e.target.value) {
     405                  this.map.setLayoutProperty(feature.id,'visibility','none');
     406                }
     407              }.bind(this));
     408            }
     409          });
     410          innerElement.appendChild(input)
     411
     412          var label = document.createElement('label')
     413          label.htmlFor = 'wp-mapbox-gl-js-'+category;;
     414          label.appendChild(document.createTextNode(category));
     415          innerElement.appendChild(label)
     416
     417          el.appendChild(innerElement);
     418        }.bind(this));
     419        return el;
     420      }
     421
     422      updateCategories(categories) {
     423        this.container.innerHTML = '';
     424        this.container.appendChild(this.addHeading());
     425        var thisCategoryDiv = this._addCategories(categories);
     426        this.container.appendChild(thisCategoryDiv);
     427      }
     428
     429      updateMapData(mapData) {
     430        this._options.mapData = mapData;
     431      }
    154432    }
    155433  });
     434
     435  function getBoundingBox(data) {
     436    var bounds = {}, coords, point, latitude, longitude;
     437
     438    coords = data.geometry.coordinates;
     439
     440    if(!isNaN(coords[0])) {
     441      longitude = coords[0];
     442      latitude = coords[1];
     443      bounds = []
     444      bounds.xMin = bounds.xMin < longitude ? bounds.xMin : longitude;
     445      bounds.xMax = bounds.xMax > longitude ? bounds.xMax : longitude;
     446      bounds.yMin = bounds.yMin < latitude ? bounds.yMin : latitude;
     447      bounds.yMax = bounds.yMax > latitude ? bounds.yMax : latitude;
     448    } else if(!isNaN(coords[0][0])) {
     449      for (var j = 0; j < coords.length; j++) {
     450        longitude = coords[j][0];
     451        latitude = coords[j][1];
     452        bounds.xMin = bounds.xMin < longitude ? bounds.xMin : longitude;
     453        bounds.xMax = bounds.xMax > longitude ? bounds.xMax : longitude;
     454        bounds.yMin = bounds.yMin < latitude ? bounds.yMin : latitude;
     455        bounds.yMax = bounds.yMax > latitude ? bounds.yMax : latitude;
     456      }
     457    } else {
     458      for (var j = 0; j < coords[0].length; j++) {
     459        longitude = coords[0][j][0];
     460        latitude = coords[0][j][1];
     461        bounds.xMin = bounds.xMin < longitude ? bounds.xMin : longitude;
     462        bounds.xMax = bounds.xMax > longitude ? bounds.xMax : longitude;
     463        bounds.yMin = bounds.yMin < latitude ? bounds.yMin : latitude;
     464        bounds.yMax = bounds.yMax > latitude ? bounds.yMax : latitude;
     465      }
     466    }
     467    var boundsToReturn = [[bounds.xMin, bounds.yMin], [bounds.xMax, bounds.yMax]];
     468    return boundsToReturn;
     469  }
    156470})(jQuery);
  • wp-mapbox-gl-js/trunk/wp-mapbox-gl-js.php

    r2356757 r2368995  
    1010 *
    1111 * @link              http://mapster.me/wp-mapbox-gl-js
    12  * @since             2.0.6
     12 * @since             3.0.0
    1313 * @package           WP_Mapbox_GL_JS
    1414 *
     
    1717 * Plugin URI:        http://mapster.me/wp-mapbox-gl-js/
    1818 * Description:       This plugin allows you to create custom Mapbox maps and display them around your site.
    19  * Version:             2.0.6
     19 * Version:             3.0.0
    2020 * Author:            Mapster Tech
    2121 * Author URI:        http://mapster.me/wp-mapbox-gl-js/
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'WP_MAPBOX_GL_JS_VERSION', '2.0.6' );
     38define( 'WP_MAPBOX_GL_JS_VERSION', '3.0.0' );
    3939
    4040/**
Note: See TracChangeset for help on using the changeset viewer.