Changeset 3433258
- Timestamp:
- 01/06/2026 06:22:27 AM (3 months ago)
- Location:
- add-multiple-marker
- Files:
-
- 94 added
- 10 edited
-
tags/1.3 (added)
-
tags/1.3/addmultiplemarker.php (added)
-
tags/1.3/admin (added)
-
tags/1.3/admin/admin-options.php (added)
-
tags/1.3/admin/css (added)
-
tags/1.3/admin/css/amm-style.css (added)
-
tags/1.3/admin/fonts (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Black.eot (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Black.svg (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Black.ttf (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Black.woff (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Black.woff2 (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Bold.eot (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Bold.svg (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Bold.ttf (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Bold.woff (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Bold.woff2 (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Book.eot (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Book.svg (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Book.ttf (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Book.woff (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Book.woff2 (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Heavy.eot (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Heavy.svg (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Heavy.ttf (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Heavy.woff (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Heavy.woff2 (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Light.eot (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Light.svg (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Light.ttf (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Light.woff (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Light.woff2 (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Medium.eot (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Medium.svg (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Medium.ttf (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Medium.woff (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Medium.woff2 (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Regular.eot (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Regular.svg (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Regular.ttf (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Regular.woff (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Regular.woff2 (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Thin.eot (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Thin.svg (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Thin.ttf (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Thin.woff (added)
-
tags/1.3/admin/fonts/SanaSansAlt-Thin.woff2 (added)
-
tags/1.3/admin/fonts/demo.html (added)
-
tags/1.3/admin/fonts/sanasansalt.css (added)
-
tags/1.3/admin/helper.php (added)
-
tags/1.3/admin/images (added)
-
tags/1.3/admin/images/Aubergine.jpg (added)
-
tags/1.3/admin/images/Dark.jpg (added)
-
tags/1.3/admin/images/Night.jpg (added)
-
tags/1.3/admin/images/Retro.jpg (added)
-
tags/1.3/admin/images/Silver.jpg (added)
-
tags/1.3/admin/images/Standard.jpg (added)
-
tags/1.3/admin/images/amm-logo.png (added)
-
tags/1.3/admin/images/dash-icon.png (added)
-
tags/1.3/admin/images/defaultmarker.png (added)
-
tags/1.3/admin/images/marker1.png (added)
-
tags/1.3/admin/images/marker2.png (added)
-
tags/1.3/admin/images/marker3.png (added)
-
tags/1.3/admin/images/svg (added)
-
tags/1.3/admin/images/svg/amm-cancel.svg (added)
-
tags/1.3/admin/images/svg/close.svg (added)
-
tags/1.3/admin/images/svg/marker.svg (added)
-
tags/1.3/admin/images/svg/menu.svg (added)
-
tags/1.3/admin/images/svg/search.svg (added)
-
tags/1.3/admin/images/svg/setting.svg (added)
-
tags/1.3/admin/images/svg/shape.svg (added)
-
tags/1.3/admin/images/svg/title.svg (added)
-
tags/1.3/admin/images/svg/trash.svg (added)
-
tags/1.3/admin/images/tools.jpg (added)
-
tags/1.3/admin/js (added)
-
tags/1.3/admin/js/amm-custom-settings.js (added)
-
tags/1.3/admin/js/amm-scripts.js (added)
-
tags/1.3/admin/js/jquery.blockUI.js (added)
-
tags/1.3/admin/map-integration.php (added)
-
tags/1.3/functions.php (added)
-
tags/1.3/index.php (added)
-
tags/1.3/languages (added)
-
tags/1.3/languages/addmultiplemarker-gu.mo (added)
-
tags/1.3/languages/addmultiplemarker-gu.po (added)
-
tags/1.3/languages/addmultiplemarker.pot (added)
-
tags/1.3/public (added)
-
tags/1.3/public/css (added)
-
tags/1.3/public/css/amm-frontend-style.css (added)
-
tags/1.3/public/js (added)
-
tags/1.3/public/js/frontendscript.js (added)
-
tags/1.3/readme.txt (added)
-
trunk/addmultiplemarker.php (modified) (5 diffs)
-
trunk/admin/admin-options.php (modified) (9 diffs)
-
trunk/admin/css/amm-style.css (modified) (58 diffs)
-
trunk/admin/helper.php (added)
-
trunk/admin/images/svg/amm-cancel.svg (added)
-
trunk/admin/js/amm-custom-settings.js (modified) (1 diff)
-
trunk/admin/js/amm-scripts.js (modified) (22 diffs)
-
trunk/admin/js/jquery.blockUI.js (added)
-
trunk/admin/map-integration.php (modified) (2 diffs)
-
trunk/functions.php (modified) (7 diffs)
-
trunk/index.php (modified) (1 diff)
-
trunk/public/js/frontendscript.js (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
add-multiple-marker/trunk/addmultiplemarker.php
r2608577 r3433258 1 1 <?php 2 2 /** 3 * Plugin Name: Add Multiple Marker 4 * Plugin URI: http://addmultiplemarker.com 5 * Description: Display Custom Multiple Markers of your company locations on Google Maps with title, icon, and show the area of your business. A feature-rich functionality without any programming that saves your 15+ hours. 6 * Author: KrishaWeb 7 * Author URI: https://www.krishaweb.com 8 * Version: 1.2 9 * Text Domain: addmultiplemarker 10 * Domain Path: /languages 3 * Plugin Name: Multi Location Marker 4 * Plugin URI: https://wordpress.org/plugins/add-multiple-marker 5 * Description: Display multiple custom location markers with titles, icons, and service areas without any technical setup. 6 * Author: KrishaWeb 7 * Author URI: https://www.krishaweb.com 8 * Version: 1.3 9 * Text Domain: add-multiple-marker 10 * Domain Path: /languages 11 * Tested up to: 6.9 12 * License: GPLv3 or later 13 * License URI: https://www.gnu.org/licenses/gpl-3.0.html 11 14 * 12 15 * @package Addmultiplemarker … … 17 20 } 18 21 // Define plugin requires constant. 19 define( 'ADDMULTIPLEMARKER_VERSION', '1. 2' );22 define( 'ADDMULTIPLEMARKER_VERSION', '1.3' ); 20 23 define( 'ADDMULTIPLEMARKER_IN_REQUIRED_WP_VERSION', '4.4' ); 21 24 define( 'ADDMULTIPLEMARKER_FILE', __FILE__ ); … … 24 27 25 28 /** 26 * register_activation_hook().27 * 29 * Register_activation_hook(). 30 * 28 31 * When a plugin is activated, this action is called. 29 32 */ … … 34 37 35 38 /** 36 * register_deactivation_hook().39 * Register_deactivation_hook(). 37 40 * 38 41 * When a plugin is deactivated, this action is called. … … 47 50 */ 48 51 function addmultiplemarker_plugin_initialize() { 49 require_once( ADDMULTIPLEMARKER_PLUGIN_DIR . '/functions.php' ); 52 require_once ADDMULTIPLEMARKER_PLUGIN_DIR . '/functions.php'; 53 require_once ADDMULTIPLEMARKER_PLUGIN_DIR . '/admin/helper.php'; 50 54 // Class calling. 51 55 $multiplemarker_obj = new Addmultiplemarker(); 52 53 56 } 54 add_action( 'init', 'addmultiplemarker_plugin_initialize' );57 add_action( 'init', 'addmultiplemarker_plugin_initialize' ); -
add-multiple-marker/trunk/admin/admin-options.php
r2116120 r3433258 1 <?php 2 /** 3 * Global settings page. 4 * 5 * @package addmultiplemarker 6 */ 7 8 if ( ! defined( 'ABSPATH' ) ) { 9 exit; 10 } 11 ?> 1 12 <div class="amm-admin-main-wrap"> 2 13 <div class="amm-map-create"> 3 14 <form class="amm-get-location" method="post" action=""> 4 <?php wp_nonce_field( ); ?>15 <?php wp_nonce_field( 'addmultiplemarker_save_map' ); ?> 5 16 <div class="amm-map-content full"> 6 17 <!-- header start --> … … 8 19 <div class="amm-container clearfix"> 9 20 <div class="amm-logo"> 10 <img src="<?php echo ADDMULTIPLEMARKER_PLUGIN_URL ?>admin/images/amm-logo.png" alt="logo">21 <img src="<?php echo esc_url( ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/images/amm-logo.png' ); ?>" alt="logo"> 11 22 </div> 12 23 <div class="sidebar-action"> 13 <img src="<?php echo ADDMULTIPLEMARKER_PLUGIN_URL ?>admin/images/svg/menu.svg" alt="menu" class="imgsvg"> 24 <img src="<?php echo esc_url( ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/images/svg/menu.svg' ); ?>" alt="menu" class="imgsvg open-sidebar"> 25 <img src="<?php echo esc_url( ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/images/svg/amm-cancel.svg' ); ?>" alt="menu" class="imgsvg close-sidebar"> 14 26 </div> 15 27 <div class="amm-search-action"> 16 <a href="javascript:;"><?php _e( 'Search Location', 'addmultiplemarker' ); ?></a>28 <a href="javascript:;"><?php esc_html_e( 'Search Location', 'add-multiple-marker' ); ?></a> 17 29 </div> 18 30 <!-- search bar start --> … … 20 32 <div class="wraps"> 21 33 <span class="amm-icon amm-search"> 22 <img src="<?php echo ADDMULTIPLEMARKER_PLUGIN_URL ?>admin/images/svg/search.svg" alt="search" class="imgsvg">34 <img src="<?php echo esc_url( ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/images/svg/search.svg' ); ?>" alt="search" class="imgsvg"> 23 35 </span> 24 36 <input type="search" id="amm_search_area" name="amm_search_area" placeholder="Search your location area" class="amm-map-search-input"> 25 37 <div class="search-close"> 26 38 <span class="amm-icon"> 27 <img src="<?php echo ADDMULTIPLEMARKER_PLUGIN_URL ?>admin/images/svg/close.svg" alt="close" class="imgsvg">39 <img src="<?php echo esc_url( ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/images/svg/close.svg' ); ?>" alt="close" class="imgsvg"> 28 40 </span> 29 41 </div> … … 47 59 <div class="amm-map-sidebar off"> 48 60 <div class="wraps"> 49 <h2><?php _e( 'Customise the map with below steps.', 'addmultiplemarker' ); ?></h2>61 <h2><?php esc_html_e( 'Customise the map with below steps.', 'add-multiple-marker' ); ?></h2> 50 62 <div class="amm-map-panel"> 51 63 <div class="amm-panel-header"> 52 64 <h3> 53 <span class="number"><?php _e( '1.', 'addmultiplemarker' ); ?></span>54 <span class="text"><?php _e( 'Select marker pin.', 'addmultiplemarker' ); ?></span>65 <span class="number"><?php esc_html_e( '1.', 'add-multiple-marker' ); ?></span> 66 <span class="text"><?php esc_html_e( 'Select marker pin.', 'add-multiple-marker' ); ?></span> 55 67 </h3> 56 68 </div> … … 58 70 <div id="amm-marker-imgs"></div> 59 71 </div> 72 <div id="drop_marker_wrap"> 73 <span>Drop pin at current location</span> 74 <button type="button" class="drop-marker-btn" id="dropMarkerBtn">Drop</button> 75 </div> 60 76 </div> 61 77 <div class="amm-map-panel"> 62 78 <div class="amm-panel-header"> 63 79 <h3> 64 <span class="number"><?php _e( '2.', 'addmultiplemarker' ); ?></span>65 <span class="text"><?php _e( 'Select shape tool color to define service area.', 'addmultiplemarker' ); ?></span>80 <span class="number"><?php esc_html_e( '2.', 'add-multiple-marker' ); ?></span> 81 <span class="text"><?php esc_html_e( 'Select shape tool color to define service area.', 'add-multiple-marker' ); ?></span> 66 82 </h3> 67 83 </div> 68 84 <div class="amm-panel-body"> 85 <div class="color-box-wrap"> 86 <span data-bgcolor="#000000" class="color-box" style="background-color: #000000;" title="#000000"></span> 87 <span data-bgcolor="#ffffff" class="color-box" style="background-color: #ffffff;" title="#ffffff"></span> 88 <span data-bgcolor="#0000ff" class="color-box" style="background-color: #0000ff;" title="#0000ff"></span> 89 <span data-bgcolor="#00ff00" class="color-box" style="background-color: #00ff00;" title="#00ff00"></span> 90 <span data-bgcolor="#ff0000" class="color-box" style="background-color: #ff0000;" title="#ff0000"></span> 91 <span data-bgcolor="#c0c0c0" class="color-box" style="background-color: #c0c0c0;" title="#c0c0c0"></span> 92 </div> 93 <span class="or">-OR-</span> 69 94 <!-- Map custom color start --> 70 95 <div id="amm-color-square"></div> 71 <input id="color-field" class="color-field" type="text" name="amm_map_color" value="<?php echo ( isset( $color ) ? $color : '#fffff' ); ?>" placeholder="<?php _e( 'color code', 'addmultiplemarker' ); ?>" onChange="createColorTags(this.value)"/>96 <input id="color-field" class="color-field" type="text" name="amm_map_color" value="<?php echo ( isset( $color ) ? esc_attr( $color ) : esc_attr( '#fffff' ) ); ?>" placeholder="<?php echo esc_attr__( 'color code', 'add-multiple-marker' ); ?>" onChange="createColorTags(this.value)"/> 72 97 <!-- Map custom color close --> 73 98 </div> … … 76 101 <div class="amm-panel-header"> 77 102 <h3> 78 <span class="number"><?php _e( '3.', 'addmultiplemarker' ); ?></span>79 <span class="text"><?php _e( 'Now you can drop marker using drawing tools inside the map or use circle/polygon tool to define service region you cover and then save the map.', 'addmultiplemarker' ); ?></span>103 <span class="number"><?php esc_html_e( '3.', 'add-multiple-marker' ); ?></span> 104 <span class="text"><?php esc_html_e( 'Now you can drop marker using drawing tools inside the map or use circle/polygon tool to define service region you cover and then save the map.', 'add-multiple-marker' ); ?></span> 80 105 </h3> 81 106 </div> 82 107 <div class="amm-panel-body"> 83 <img src="<?php echo ADDMULTIPLEMARKER_PLUGIN_URL ?>admin/images/tools.jpg" alt="tools">108 <img src="<?php echo esc_url( ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/images/tools.jpg' ); ?>" alt="tools"> 84 109 </div> 85 110 </div> … … 87 112 <div class="amm-panel-body"> 88 113 <div class="amm-short-code"> 89 <p><?php _e( 'After making all changes, save the map and copy below shortcode to apply in different page of website.', 'addmultiplemarker' ); ?></p>114 <p><?php esc_html_e( 'After making all changes, save the map and copy below shortcode to apply in different page of website.', 'add-multiple-marker' ); ?></p> 90 115 <div class="input-group"> 91 116 <input type="text" name="shortcode" readonly class="form-control" value="[addmultiplemarker]" disabled="disabled"> … … 95 120 </div> 96 121 </div> 97 <span class="reset-maps" id="map-resets"><?php _e( 'Reset Map', 'addmultiplemarker' ); ?></span>122 <span class="reset-maps" id="map-resets"><?php esc_html_e( 'Reset Map', 'add-multiple-marker' ); ?></span> 98 123 </div> 99 124 </div> 100 125 </div> 101 126 <div class="amm-map-apply"> 102 <div class="amm-map-delete amm-sidebar-close">103 <span class="amm-icon">104 <img src="<?php echo ADDMULTIPLEMARKER_PLUGIN_URL ?>admin/images/svg/amm-cancel.svg" alt="trash" class="imgsvg">105 </span>106 </div>107 127 <div class="amm-map-delete"> 108 128 <span id="delete-shape"> 109 129 <span class="amm-icon"> 110 <img src="<?php echo ADDMULTIPLEMARKER_PLUGIN_URL ?>admin/images/svg/trash.svg" alt="trash" class="imgsvg">130 <img src="<?php echo esc_url( ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/images/svg/trash.svg' ); ?>" alt="trash" class="imgsvg"> 111 131 </span> 112 132 </span> … … 123 143 <textarea class="amm_marker_positions" id="amm_marker_positions" name="amm_marker_positions"></textarea> 124 144 <textarea name="amm_map_control" class="amm_marker_control" id="amm_map_control"></textarea> 125 <?php $retrieve_map_settings = get_option( 'amm_map_setting' ); ?> 126 <input class="amm_map_api_key" type="text" name="amm_api_key" value="<?php echo ( $retrieve_map_settings ? $retrieve_map_settings['api'] : ''); ?>" placeholder=""> 145 <?php 146 $retrieve_map_settings = get_option( 'amm_map_setting' ); 147 $api_key = isset( $retrieve_map_settings['api'] ) ? $retrieve_map_settings['api'] : ''; 148 ?> 149 <input class="amm_map_api_key" type="text" name="amm_api_key" value="<?php echo esc_attr( $api_key ); ?>" placeholder=""> 127 150 <!-- hidden area close --> 128 151 </form> 152 <?php 153 if ( ! $api_key ) { 154 wp_nonce_field( 'amm_save_map_api', 'amm_api_key_nonce' ); 155 } else { 156 wp_nonce_field( 'amm_reset_map', 'amm_reset_map_nonce' ); 157 } 158 ?> 129 159 </div> 130 160 </div> -
add-multiple-marker/trunk/admin/css/amm-style.css
r2608577 r3433258 12 12 height: 100%; 13 13 } 14 14 15 /* clearfix */ 15 16 .clearfix:after { … … 29 30 height: 1%; 30 31 } 32 31 33 a { 32 34 outline: none; … … 34 36 border: 0px; 35 37 } 38 36 39 a:focus { 37 40 outline: none; … … 39 42 box-shadow: none; 40 43 } 44 41 45 /* amm admin main wrap */ 42 46 .amm-admin-main-wrap { … … 50 54 padding: 0px; 51 55 } 56 52 57 .left-align-section { 53 58 float: left; … … 55 60 margin-right: 15px; 56 61 } 62 57 63 .right-align-section { 58 64 float: left; … … 60 66 margin-left: 15px; 61 67 } 68 62 69 .amm-admin-main-wrap img { 63 70 max-width: 100%; … … 78 85 height: 100%; 79 86 } 87 80 88 .amm_marker_type, 81 89 .amm_marker_positions, … … 84 92 display: none; 85 93 } 94 86 95 .amm-icon { 87 96 line-height: normal; … … 90 99 height: 28px; 91 100 } 101 92 102 .amm-icon .imgsvg { 93 103 width: 100%; … … 97 107 margin: 0; 98 108 } 109 99 110 /* amm header start */ 100 111 .amm-map-header { … … 108 119 left: 160px; 109 120 } 121 110 122 .amm-map-header.full { 111 123 right: 0; … … 113 125 left: 160px; 114 126 } 127 115 128 .amm-map-header .amm-container { 116 129 padding: 10px 15px; … … 122 135 float: left; 123 136 } 137 124 138 .amm-search-action { 125 139 float: right; 126 140 } 141 127 142 .amm-search-action a { 128 143 cursor: pointer; … … 138 153 border-radius: 4px; 139 154 } 155 140 156 .amm-search { 141 157 cursor: pointer; 142 158 } 159 143 160 .amm-menu { 144 161 cursor: pointer; 145 162 } 163 146 164 /* amm header close */ 147 165 /* amm body start */ … … 152 170 padding-top: 100px; 153 171 } 172 154 173 .amm-map { 155 174 height: 100%; 156 175 } 176 157 177 #amm-map { 158 178 height: 100%; 159 179 clear: both; 160 180 } 181 161 182 /* amm body close */ 162 183 /* amm search start */ … … 174 195 display: none; 175 196 } 197 176 198 .amm-map-search-bar .wraps { 177 199 position: absolute; … … 183 205 left: 25px; 184 206 } 207 185 208 .amm-map-search-bar.on { 186 209 display: block; 187 210 } 211 188 212 .amm-map-search-bar .amm-icon { 189 213 display: inline-block; … … 193 217 margin-top: 10px; 194 218 } 219 195 220 .amm-map-search-input, 196 221 input[type="search"] { … … 215 240 transition: border 0.5s ease-out; 216 241 } 242 217 243 .amm-map-search-bar .amm-map-search-input:focus { 218 244 box-shadow: none; … … 221 247 background-color: transparent; 222 248 } 249 223 250 .amm-map-search-bar .search-close { 224 251 position: absolute; … … 234 261 text-align: center; 235 262 } 263 236 264 .amm-map-search-bar .search-close .amm-icon { 237 265 width: 15px; … … 245 273 margin: auto; 246 274 } 275 247 276 .amm-map-search-bar .search-close .amm-icon .imgsvg { 248 277 width: 100%; 249 278 height: 100%; 250 279 } 280 251 281 .amm-map-search-bar .search-close .amm-icon .imgsvg path { 252 282 fill: #37a1fc; 253 283 } 284 254 285 /* amm search close */ 255 286 .amm-map-content { 256 287 width: calc(100% - 340px); 257 288 } 289 258 290 .amm-map-content.full { 259 291 width: 100%; 260 292 } 293 261 294 .amm-map-sidebar { 262 295 width: 355px; … … 268 301 z-index: 1112; 269 302 } 303 270 304 .amm-map-sidebar.off { 271 305 right: -355px; 272 306 } 307 273 308 .amm-map-sidebar .wraps { 274 309 padding: 30px; … … 276 311 overflow: auto; 277 312 } 313 278 314 /* amm setting start */ 279 315 .amm-map-title-bar { … … 295 331 border-radius: 5px; 296 332 } 333 297 334 .amm-map-marker-bar { 298 335 position: absolute; … … 313 350 border-radius: 5px; 314 351 } 352 315 353 .amm-map-marker-bar .map-images { 316 354 height: 30px; … … 321 359 padding: 5px; 322 360 } 361 323 362 .amm-map-shape-bar { 324 363 position: absolute; … … 339 378 border-radius: 5px; 340 379 } 380 341 381 .amm-map-shape-bar .color-button { 342 382 width: 20px; … … 347 387 margin-right: 5px; 348 388 } 389 349 390 .amm-map-shape-bar .color-button:last-child { 350 391 margin-right: 0px; 351 392 } 393 352 394 .amm-map-apply { 353 395 position: absolute; … … 359 401 color: #ffffff; 360 402 } 403 361 404 .amm-map-save { 362 405 display: inline-block; 363 406 } 407 364 408 .amm-map-save .submit { 365 409 padding: 15px 25px; … … 374 418 border-radius: 4px; 375 419 } 420 376 421 .amm-map-delete { 377 422 padding: 10px 25px; … … 388 433 border-radius: 4px; 389 434 } 435 390 436 .amm-map-delete .imgsvg { 391 437 width: 20px; 392 438 height: 20px; 393 439 } 440 394 441 .amm-map-delete .imgsvg path { 395 442 fill: #fff; 396 443 } 444 397 445 .amm-map-panel { 398 446 padding: 0; 399 447 margin: 0 0 25px; 400 448 } 449 401 450 .amm-map-panel .amm-panel-header { 402 451 display: block; 403 452 } 453 404 454 .amm-map-panel .amm-panel-header h3 { 405 455 display: block; 406 456 position: relative; 407 457 } 458 408 459 .amm-map-panel .amm-panel-header h3 .number { 409 460 position: absolute; … … 413 464 font-weight: 400; 414 465 } 466 415 467 .amm-map-panel .amm-panel-header h3 .text { 416 468 font-size: 16px; … … 421 473 line-height: 1.4; 422 474 } 475 423 476 .amm-map-panel .amm-panel-body { 424 477 padding: 0 15px; 425 478 } 479 426 480 #amm-marker-imgs { 427 481 display: block; 428 482 } 483 429 484 #amm-marker-imgs div { 430 485 width: 55px; … … 438 493 position: relative; 439 494 } 495 440 496 #amm-marker-imgs div img { 441 497 position: absolute; … … 446 502 margin: auto; 447 503 } 504 448 505 #amm-marker-imgs div:last-child { 449 506 margin-right: 0px; 450 507 } 508 451 509 .amm-short-code { 452 510 border: 1px solid #d5d5d5; … … 457 515 border-radius: 4px; 458 516 } 517 459 518 .amm-short-code .input-group { 460 519 position: relative; 461 520 width: 100%; 462 521 } 522 463 523 .amm-short-code .input-group .form-control { 464 524 width: 100%; … … 472 532 box-shadow: none; 473 533 } 534 474 535 .amm-short-code .input-group .input-group-addon .submit { 475 536 position: absolute; … … 495 556 box-shadow: none; 496 557 } 558 497 559 .amm-short-code .input-group .input-group-addon .submit:focus { 498 560 outline: none; 499 561 box-shadow: none; 500 562 } 563 501 564 .sidebar-action { 502 565 position: relative; … … 510 573 display: none; 511 574 } 575 512 576 .sidebar-action .imgsvg { 513 577 width: 30px; … … 520 584 margin: auto; 521 585 } 586 522 587 .sidebar-action .imgsvg path { 523 588 fill: #fff; 524 589 } 590 591 .close-sidebar { 592 display: none; 593 } 594 525 595 @media (min-width: 1501px) { 526 596 .amm-sidebar-close { … … 528 598 } 529 599 } 600 530 601 @media (min-width: 200px) and (max-width: 1500px) { 531 602 .sidebar-action { 532 603 display: block; 533 604 } 605 534 606 .amm-map-content { 535 607 width: 100%; 536 608 } 609 537 610 .amm-map-header { 538 611 width: 100%; … … 541 614 } 542 615 } 616 543 617 @media (min-width: 783px) and (max-width: 960px) { 544 618 .amm-map-header.full { … … 547 621 } 548 622 } 623 549 624 @media (min-width: 200px) and (max-width: 782px) { 550 625 .amm-map-header.full { … … 552 627 left: 0px; 553 628 } 629 630 .amm-map-integration-wrap .left-align-section, 631 .amm-map-integration-wrap .right-align-section { 632 width: 100%; 633 margin-left: 0px; 634 margin-bottom: 40px; 635 } 554 636 } 555 637 … … 557 639 padding: 50px 20px; 558 640 } 641 559 642 .amm-panel { 560 643 padding: 0; … … 562 645 position: relative; 563 646 } 647 564 648 .amm-panel:last-child { 565 649 margin-bottom: 0px; 566 650 } 651 567 652 .amm-panel fieldset { 568 653 padding: 5px 15px 15px; 569 654 margin: 0; 570 655 background-color: #fff; 571 } 656 line-height: 2; 657 } 658 572 659 .amm-panel fieldset legend { 573 660 width: 100%; … … 579 666 top: -20px; 580 667 } 668 581 669 .amm-panel .label { 582 670 display: inline-block; … … 584 672 font-size: 13px; 585 673 } 674 586 675 .amm-call-to-btn { 587 676 padding: 0; 588 margin: 0; 589 display: block; 590 width: 100%; 591 } 677 margin: 0px 0px 10px 0px; 678 display: block; 679 width: 100%; 680 } 681 592 682 .amm-call-to-btn .submit { 593 683 padding: 15px 25px; … … 602 692 border-radius: 4px; 603 693 } 694 604 695 .amm-input { 605 696 padding: 6px 12px; … … 612 703 width: 100%; 613 704 } 705 614 706 .amm-map-theme-section.amm-panel .label { 615 707 position: relative; 616 708 margin-bottom: 10px; 617 709 } 710 618 711 .amm-map-theme-section.amm-panel .label .text { 619 712 opacity: 0; … … 623 716 top: 0; 624 717 } 718 625 719 .reset-maps { 626 720 padding: 15px 25px; … … 638 732 text-align: center; 639 733 } 734 640 735 .success-msg { 641 736 font-size: 16px; … … 644 739 font-weight: bold; 645 740 } 741 646 742 span.error { 743 display: block; 744 margin-top: 10px; 647 745 color: #dc3232; 648 746 } 747 649 748 .amm-maps-message { 650 749 display: inline-block; … … 659 758 margin: 0 auto !important; 660 759 } 760 661 761 #amm-modal-map-api { 662 762 padding: 20px; 663 763 } 764 664 765 #amm-modal-map-api .amm-modal-map-api-form { 665 766 position: relative; 666 } 767 display: flex; 768 align-items: center; 769 } 770 667 771 #amm-modal-map-api .amm-panel { 668 772 margin: 0; 669 position: relative; 670 } 773 width: 100%; 774 position: relative; 775 } 776 671 777 #amm-modal-map-api .amm-panel fieldset { 672 778 padding: 0; 673 779 } 780 674 781 #amm-modal-map-api .amm-input { 675 782 padding-right: 100px; 676 783 height: 50px; 677 784 } 785 678 786 #amm-modal-map-api .amm-call-to-btn { 679 787 position: absolute; 680 788 right: 5px; 681 top: 8px;789 margin-bottom: 0; 682 790 width: auto; 683 791 } 792 684 793 #amm-modal-map-api .amm-call-to-btn .submit { 685 794 padding: 7px 25px 11px; 686 795 } 796 687 797 #amm-modal-map-api h3 { 688 798 margin-top: 0; … … 726 836 width: calc(100% - 200px); 727 837 position: relative; 838 } 839 840 .amm-map-panel .drop-marker-btn { 841 display: block; 842 padding: 10px 20px; 843 color: #ffffff; 844 background-color: #abb02e; 845 border: none; 846 border-radius: 4px; 847 margin-top: 10px; 848 font-size: 16px; 849 cursor: pointer; 850 } 851 852 .amm-panel-body .color-box-wrap { 853 display: flex; 854 flex-direction: row; 855 padding: 10px 0; 856 gap: 10px; 857 } 858 859 .amm-panel-body .color-box-wrap .color-box { 860 display: block; 861 width: 20px; 862 height: 20px; 863 border: 1px solid black; 864 } 865 866 .amm-panel-body .color-box-wrap .color-box:hover { 867 cursor: pointer; 868 } 869 870 .amm-panel-body .or { 871 display: block; 872 padding-bottom: 10px; 873 font-style: italic; 728 874 } 729 875 … … 739 885 740 886 @media (max-width: 960px) { 887 741 888 #wpfooter, 742 889 body.toplevel_page_addmultiplemarker #wpfooter { -
add-multiple-marker/trunk/admin/js/amm-custom-settings.js
r2116120 r3433258 1 // jQuery( window ).on( 'load resize', function() { 2 // mapStructure(); 3 // }); 4 // AIzaSyDHlzcHiFP9Hktn7-vFQGs6eOkbfYMhI5o 5 jQuery( document ).ready( function( $ ) { 1 jQuery(document).ready(function ($) { 6 2 let mapApiKeyValue = jQuery('input[name="amm_api_key"]').val(); 7 if ( mapApiKeyValue == '' ){8 var mapAPIKeyInput = '<div id="amm-modal-map-api"><h3>Enter Your Google Map Api Key</h3><div class="amm-modal-map-api-form"><div class="amm-api-section amm-panel"><fieldset><input class="amm-input" type="text" name="amm_modal_api_key" value="" placeholder="Please enter your map API key here">< span class="error error-span"></span></fieldset></div><div class="amm-call-to-btn"><button value="Save" class="submit amm-modal-save-btn">save</button></div></div></div>';9 $.blockUI({ message: mapAPIKeyInput }); 3 if (mapApiKeyValue == '') { 4 var mapAPIKeyInput = '<div id="amm-modal-map-api"><h3>Enter Your Google Map Api Key</h3><div class="amm-modal-map-api-form"><div class="amm-api-section amm-panel"><fieldset><input class="amm-input" type="text" name="amm_modal_api_key" value="" placeholder="Please enter your map API key here"></fieldset></div><div class="amm-call-to-btn"><button value="Save" class="submit amm-modal-save-btn">save</button></div></div><span class="error error-span"></span></div>'; 5 $.blockUI({ message: mapAPIKeyInput }); 10 6 } 11 // imgSvg(); 12 // ammSearch(); 7 8 $('.sidebar-action').on('click', function () { 9 $('.sidebar-action svg').toggle(); 10 }); 13 11 }); 14 12 15 jQuery(document).on('click', '#amm-modal-map-api button', function(){13 jQuery(document).on('click', '#amm-modal-map-api button', function () { 16 14 var _this = jQuery(this).parents('#amm-modal-map-api'); 17 15 var APIKeyValue = _this.find('input').val(); 18 16 var saveApiKeydata = { 19 action: 'amm_save_map_api', 20 apiKeyValue: APIKeyValue 17 action: 'addmultiplemarker_save_map_api', 18 apiKeyValue: APIKeyValue, 19 nonce: jQuery('#amm_api_key_nonce').val().trim() 21 20 } 22 21 23 jQuery.post(amm_plugin_custom_obj.ajax_url, saveApiKeydata, 24 function( response ){ 25 var ajax_result = jQuery.parseJSON( response ); 26 if (ajax_result.result == '1'){ 27 window.location = window.location.href; 28 }else{ 29 _this.find('span').text(ajax_result.message); 22 jQuery.post(amm_plugin_custom_obj.ajax_url, saveApiKeydata, 23 function (response) { 24 if (response.success) { 25 window.location = window.location.href; 26 } else { 27 _this.find('span').text(response.data.message); 30 28 } 31 })29 }) 32 30 }) 33 -
add-multiple-marker/trunk/admin/js/amm-scripts.js
r2608577 r3433258 2 2 var map; 3 3 var drawingManager; 4 5 const markerPositionsInput = document.getElementById('amm_marker_positions'); 6 const markerTypeInput = document.getElementById('amm_marker_type') 4 7 5 8 var selectedShape; … … 14 17 var allDrawShape = []; 15 18 var drawShapeDetail = []; 19 let markerArray = []; 20 let dropMarkerBtnState = true; 21 let oldMapLatlngs = []; 22 let currentLocation; 16 23 17 24 var markerImg = [ … … 22 29 ]; 23 30 24 var style = amm_plugin_obj.map_settings.map_theme; 25 var selectedStyle, 26 standard = [], 27 silver = [{"elementType":"geometry","stylers":[{"color":"#f5f5f5"}]},{"elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"elementType":"labels.text.fill","stylers":[{"color":"#616161"}]},{"elementType":"labels.text.stroke","stylers":[{"color":"#f5f5f5"}]},{"featureType":"administrative.land_parcel","elementType":"labels.text.fill","stylers":[{"color":"#bdbdbd"}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#eeeeee"}]},{"featureType":"poi","elementType":"labels.text.fill","stylers":[{"color":"#757575"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#e5e5e5"}]},{"featureType":"poi.park","elementType":"labels.text.fill","stylers":[{"color":"#9e9e9e"}]},{"featureType":"road","elementType":"geometry","stylers":[{"color":"#ffffff"}]},{"featureType":"road.arterial","elementType":"labels.text.fill","stylers":[{"color":"#757575"}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#dadada"}]},{"featureType":"road.highway","elementType":"labels.text.fill","stylers":[{"color":"#616161"}]},{"featureType":"road.local","elementType":"labels.text.fill","stylers":[{"color":"#9e9e9e"}]},{"featureType":"transit.line","elementType":"geometry","stylers":[{"color":"#e5e5e5"}]},{"featureType":"transit.station","elementType":"geometry","stylers":[{"color":"#eeeeee"}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#c9c9c9"}]},{"featureType":"water","elementType":"labels.text.fill","stylers":[{"color":"#9e9e9e"}]}], 28 retro = [{"elementType":"geometry","stylers":[{"color":"#ebe3cd"}]},{"elementType":"labels.text.fill","stylers":[{"color":"#523735"}]},{"elementType":"labels.text.stroke","stylers":[{"color":"#f5f1e6"}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#c9b2a6"}]},{"featureType":"administrative.land_parcel","elementType":"geometry.stroke","stylers":[{"color":"#dcd2be"}]},{"featureType":"administrative.land_parcel","elementType":"labels.text.fill","stylers":[{"color":"#ae9e90"}]},{"featureType":"landscape.natural","elementType":"geometry","stylers":[{"color":"#dfd2ae"}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#dfd2ae"}]},{"featureType":"poi","elementType":"labels.text.fill","stylers":[{"color":"#93817c"}]},{"featureType":"poi.park","elementType":"geometry.fill","stylers":[{"color":"#a5b076"}]},{"featureType":"poi.park","elementType":"labels.text.fill","stylers":[{"color":"#447530"}]},{"featureType":"road","elementType":"geometry","stylers":[{"color":"#f5f1e6"}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#fdfcf8"}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#f8c967"}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#e9bc62"}]},{"featureType":"road.highway.controlled_access","elementType":"geometry","stylers":[{"color":"#e98d58"}]},{"featureType":"road.highway.controlled_access","elementType":"geometry.stroke","stylers":[{"color":"#db8555"}]},{"featureType":"road.local","elementType":"labels.text.fill","stylers":[{"color":"#806b63"}]},{"featureType":"transit.line","elementType":"geometry","stylers":[{"color":"#dfd2ae"}]},{"featureType":"transit.line","elementType":"labels.text.fill","stylers":[{"color":"#8f7d77"}]},{"featureType":"transit.line","elementType":"labels.text.stroke","stylers":[{"color":"#ebe3cd"}]},{"featureType":"transit.station","elementType":"geometry","stylers":[{"color":"#dfd2ae"}]},{"featureType":"water","elementType":"geometry.fill","stylers":[{"color":"#b9d3c2"}]},{"featureType":"water","elementType":"labels.text.fill","stylers":[{"color":"#92998d"}]}], 29 dark = [{"elementType":"geometry","stylers":[{"color":"#212121"}]},{"elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"elementType":"labels.text.fill","stylers":[{"color":"#757575"}]},{"elementType":"labels.text.stroke","stylers":[{"color":"#212121"}]},{"featureType":"administrative","elementType":"geometry","stylers":[{"color":"#757575"}]},{"featureType":"administrative.country","elementType":"labels.text.fill","stylers":[{"color":"#9e9e9e"}]},{"featureType":"administrative.land_parcel","stylers":[{"visibility":"off"}]},{"featureType":"administrative.locality","elementType":"labels.text.fill","stylers":[{"color":"#bdbdbd"}]},{"featureType":"poi","elementType":"labels.text.fill","stylers":[{"color":"#757575"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#181818"}]},{"featureType":"poi.park","elementType":"labels.text.fill","stylers":[{"color":"#616161"}]},{"featureType":"poi.park","elementType":"labels.text.stroke","stylers":[{"color":"#1b1b1b"}]},{"featureType":"road","elementType":"geometry.fill","stylers":[{"color":"#2c2c2c"}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"color":"#8a8a8a"}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#373737"}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#3c3c3c"}]},{"featureType":"road.highway.controlled_access","elementType":"geometry","stylers":[{"color":"#4e4e4e"}]},{"featureType":"road.local","elementType":"labels.text.fill","stylers":[{"color":"#616161"}]},{"featureType":"transit","elementType":"labels.text.fill","stylers":[{"color":"#757575"}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#000000"}]},{"featureType":"water","elementType":"labels.text.fill","stylers":[{"color":"#3d3d3d"}]}], 30 night = [{"elementType":"geometry","stylers":[{"color":"#242f3e"}]},{"elementType":"labels.text.fill","stylers":[{"color":"#746855"}]},{"elementType":"labels.text.stroke","stylers":[{"color":"#242f3e"}]},{"featureType":"administrative.locality","elementType":"labels.text.fill","stylers":[{"color":"#d59563"}]},{"featureType":"poi","elementType":"labels.text.fill","stylers":[{"color":"#d59563"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#263c3f"}]},{"featureType":"poi.park","elementType":"labels.text.fill","stylers":[{"color":"#6b9a76"}]},{"featureType":"road","elementType":"geometry","stylers":[{"color":"#38414e"}]},{"featureType":"road","elementType":"geometry.stroke","stylers":[{"color":"#212a37"}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"color":"#9ca5b3"}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#746855"}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#1f2835"}]},{"featureType":"road.highway","elementType":"labels.text.fill","stylers":[{"color":"#f3d19c"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#2f3948"}]},{"featureType":"transit.station","elementType":"labels.text.fill","stylers":[{"color":"#d59563"}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#17263c"}]},{"featureType":"water","elementType":"labels.text.fill","stylers":[{"color":"#515c6d"}]},{"featureType":"water","elementType":"labels.text.stroke","stylers":[{"color":"#17263c"}]}], 31 aubergine = [{"elementType":"geometry","stylers":[{"color":"#1d2c4d"}]},{"elementType":"labels.text.fill","stylers":[{"color":"#8ec3b9"}]},{"elementType":"labels.text.stroke","stylers":[{"color":"#1a3646"}]},{"featureType":"administrative.country","elementType":"geometry.stroke","stylers":[{"color":"#4b6878"}]},{"featureType":"administrative.land_parcel","elementType":"labels.text.fill","stylers":[{"color":"#64779e"}]},{"featureType":"administrative.province","elementType":"geometry.stroke","stylers":[{"color":"#4b6878"}]},{"featureType":"landscape.man_made","elementType":"geometry.stroke","stylers":[{"color":"#334e87"}]},{"featureType":"landscape.natural","elementType":"geometry","stylers":[{"color":"#023e58"}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#283d6a"}]},{"featureType":"poi","elementType":"labels.text.fill","stylers":[{"color":"#6f9ba5"}]},{"featureType":"poi","elementType":"labels.text.stroke","stylers":[{"color":"#1d2c4d"}]},{"featureType":"poi.park","elementType":"geometry.fill","stylers":[{"color":"#023e58"}]},{"featureType":"poi.park","elementType":"labels.text.fill","stylers":[{"color":"#3C7680"}]},{"featureType":"road","elementType":"geometry","stylers":[{"color":"#304a7d"}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"color":"#98a5be"}]},{"featureType":"road","elementType":"labels.text.stroke","stylers":[{"color":"#1d2c4d"}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#2c6675"}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#255763"}]},{"featureType":"road.highway","elementType":"labels.text.fill","stylers":[{"color":"#b0d5ce"}]},{"featureType":"road.highway","elementType":"labels.text.stroke","stylers":[{"color":"#023e58"}]},{"featureType":"transit","elementType":"labels.text.fill","stylers":[{"color":"#98a5be"}]},{"featureType":"transit","elementType":"labels.text.stroke","stylers":[{"color":"#1d2c4d"}]},{"featureType":"transit.line","elementType":"geometry.fill","stylers":[{"color":"#283d6a"}]},{"featureType":"transit.station","elementType":"geometry","stylers":[{"color":"#3a4762"}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#0e1626"}]},{"featureType":"water","elementType":"labels.text.fill","stylers":[{"color":"#4e6d70"}]}]; 32 33 var mapStyleType = amm_plugin_obj.map_settings.map_style; 34 35 switch(style){ 36 case "silver": 37 selectedStyle = silver; 38 break; 39 case "retro": 40 selectedStyle = retro; 41 break; 42 case "dark": 43 selectedStyle = dark; 44 break; 45 case "night": 46 selectedStyle = night; 47 break; 48 case "aubergine": 49 selectedStyle = aubergine; 50 break; 51 default: 52 selectedStyle = standard; 53 } 31 const mapSettings = amm_plugin_obj.map_settings; 32 const mapStyleType = mapSettings.map_theme; 33 const mapStyles = { 34 standard: [], 35 silver: [{ "elementType": "geometry", "stylers": [{ "color": "#f5f5f5" }] }, { "elementType": "labels.icon", "stylers": [{ "visibility": "off" }] }, { "elementType": "labels.text.fill", "stylers": [{ "color": "#616161" }] }, { "elementType": "labels.text.stroke", "stylers": [{ "color": "#f5f5f5" }] }, { "featureType": "administrative.land_parcel", "elementType": "labels.text.fill", "stylers": [{ "color": "#bdbdbd" }] }, { "featureType": "poi", "elementType": "geometry", "stylers": [{ "color": "#eeeeee" }] }, { "featureType": "poi", "elementType": "labels.text.fill", "stylers": [{ "color": "#757575" }] }, { "featureType": "poi.park", "elementType": "geometry", "stylers": [{ "color": "#e5e5e5" }] }, { "featureType": "poi.park", "elementType": "labels.text.fill", "stylers": [{ "color": "#9e9e9e" }] }, { "featureType": "road", "elementType": "geometry", "stylers": [{ "color": "#ffffff" }] }, { "featureType": "road.arterial", "elementType": "labels.text.fill", "stylers": [{ "color": "#757575" }] }, { "featureType": "road.highway", "elementType": "geometry", "stylers": [{ "color": "#dadada" }] }, { "featureType": "road.highway", "elementType": "labels.text.fill", "stylers": [{ "color": "#616161" }] }, { "featureType": "road.local", "elementType": "labels.text.fill", "stylers": [{ "color": "#9e9e9e" }] }, { "featureType": "transit.line", "elementType": "geometry", "stylers": [{ "color": "#e5e5e5" }] }, { "featureType": "transit.station", "elementType": "geometry", "stylers": [{ "color": "#eeeeee" }] }, { "featureType": "water", "elementType": "geometry", "stylers": [{ "color": "#c9c9c9" }] }, { "featureType": "water", "elementType": "labels.text.fill", "stylers": [{ "color": "#9e9e9e" }] }], 36 retro: [{ "elementType": "geometry", "stylers": [{ "color": "#ebe3cd" }] }, { "elementType": "labels.text.fill", "stylers": [{ "color": "#523735" }] }, { "elementType": "labels.text.stroke", "stylers": [{ "color": "#f5f1e6" }] }, { "featureType": "administrative", "elementType": "geometry.stroke", "stylers": [{ "color": "#c9b2a6" }] }, { "featureType": "administrative.land_parcel", "elementType": "geometry.stroke", "stylers": [{ "color": "#dcd2be" }] }, { "featureType": "administrative.land_parcel", "elementType": "labels.text.fill", "stylers": [{ "color": "#ae9e90" }] }, { "featureType": "landscape.natural", "elementType": "geometry", "stylers": [{ "color": "#dfd2ae" }] }, { "featureType": "poi", "elementType": "geometry", "stylers": [{ "color": "#dfd2ae" }] }, { "featureType": "poi", "elementType": "labels.text.fill", "stylers": [{ "color": "#93817c" }] }, { "featureType": "poi.park", "elementType": "geometry.fill", "stylers": [{ "color": "#a5b076" }] }, { "featureType": "poi.park", "elementType": "labels.text.fill", "stylers": [{ "color": "#447530" }] }, { "featureType": "road", "elementType": "geometry", "stylers": [{ "color": "#f5f1e6" }] }, { "featureType": "road.arterial", "elementType": "geometry", "stylers": [{ "color": "#fdfcf8" }] }, { "featureType": "road.highway", "elementType": "geometry", "stylers": [{ "color": "#f8c967" }] }, { "featureType": "road.highway", "elementType": "geometry.stroke", "stylers": [{ "color": "#e9bc62" }] }, { "featureType": "road.highway.controlled_access", "elementType": "geometry", "stylers": [{ "color": "#e98d58" }] }, { "featureType": "road.highway.controlled_access", "elementType": "geometry.stroke", "stylers": [{ "color": "#db8555" }] }, { "featureType": "road.local", "elementType": "labels.text.fill", "stylers": [{ "color": "#806b63" }] }, { "featureType": "transit.line", "elementType": "geometry", "stylers": [{ "color": "#dfd2ae" }] }, { "featureType": "transit.line", "elementType": "labels.text.fill", "stylers": [{ "color": "#8f7d77" }] }, { "featureType": "transit.line", "elementType": "labels.text.stroke", "stylers": [{ "color": "#ebe3cd" }] }, { "featureType": "transit.station", "elementType": "geometry", "stylers": [{ "color": "#dfd2ae" }] }, { "featureType": "water", "elementType": "geometry.fill", "stylers": [{ "color": "#b9d3c2" }] }, { "featureType": "water", "elementType": "labels.text.fill", "stylers": [{ "color": "#92998d" }] }], 37 dark: [{ "elementType": "geometry", "stylers": [{ "color": "#212121" }] }, { "elementType": "labels.icon", "stylers": [{ "visibility": "off" }] }, { "elementType": "labels.text.fill", "stylers": [{ "color": "#757575" }] }, { "elementType": "labels.text.stroke", "stylers": [{ "color": "#212121" }] }, { "featureType": "administrative", "elementType": "geometry", "stylers": [{ "color": "#757575" }] }, { "featureType": "administrative.country", "elementType": "labels.text.fill", "stylers": [{ "color": "#9e9e9e" }] }, { "featureType": "administrative.land_parcel", "stylers": [{ "visibility": "off" }] }, { "featureType": "administrative.locality", "elementType": "labels.text.fill", "stylers": [{ "color": "#bdbdbd" }] }, { "featureType": "poi", "elementType": "labels.text.fill", "stylers": [{ "color": "#757575" }] }, { "featureType": "poi.park", "elementType": "geometry", "stylers": [{ "color": "#181818" }] }, { "featureType": "poi.park", "elementType": "labels.text.fill", "stylers": [{ "color": "#616161" }] }, { "featureType": "poi.park", "elementType": "labels.text.stroke", "stylers": [{ "color": "#1b1b1b" }] }, { "featureType": "road", "elementType": "geometry.fill", "stylers": [{ "color": "#2c2c2c" }] }, { "featureType": "road", "elementType": "labels.text.fill", "stylers": [{ "color": "#8a8a8a" }] }, { "featureType": "road.arterial", "elementType": "geometry", "stylers": [{ "color": "#373737" }] }, { "featureType": "road.highway", "elementType": "geometry", "stylers": [{ "color": "#3c3c3c" }] }, { "featureType": "road.highway.controlled_access", "elementType": "geometry", "stylers": [{ "color": "#4e4e4e" }] }, { "featureType": "road.local", "elementType": "labels.text.fill", "stylers": [{ "color": "#616161" }] }, { "featureType": "transit", "elementType": "labels.text.fill", "stylers": [{ "color": "#757575" }] }, { "featureType": "water", "elementType": "geometry", "stylers": [{ "color": "#000000" }] }, { "featureType": "water", "elementType": "labels.text.fill", "stylers": [{ "color": "#3d3d3d" }] }], 38 night: [{ "elementType": "geometry", "stylers": [{ "color": "#242f3e" }] }, { "elementType": "labels.text.fill", "stylers": [{ "color": "#746855" }] }, { "elementType": "labels.text.stroke", "stylers": [{ "color": "#242f3e" }] }, { "featureType": "administrative.locality", "elementType": "labels.text.fill", "stylers": [{ "color": "#d59563" }] }, { "featureType": "poi", "elementType": "labels.text.fill", "stylers": [{ "color": "#d59563" }] }, { "featureType": "poi.park", "elementType": "geometry", "stylers": [{ "color": "#263c3f" }] }, { "featureType": "poi.park", "elementType": "labels.text.fill", "stylers": [{ "color": "#6b9a76" }] }, { "featureType": "road", "elementType": "geometry", "stylers": [{ "color": "#38414e" }] }, { "featureType": "road", "elementType": "geometry.stroke", "stylers": [{ "color": "#212a37" }] }, { "featureType": "road", "elementType": "labels.text.fill", "stylers": [{ "color": "#9ca5b3" }] }, { "featureType": "road.highway", "elementType": "geometry", "stylers": [{ "color": "#746855" }] }, { "featureType": "road.highway", "elementType": "geometry.stroke", "stylers": [{ "color": "#1f2835" }] }, { "featureType": "road.highway", "elementType": "labels.text.fill", "stylers": [{ "color": "#f3d19c" }] }, { "featureType": "transit", "elementType": "geometry", "stylers": [{ "color": "#2f3948" }] }, { "featureType": "transit.station", "elementType": "labels.text.fill", "stylers": [{ "color": "#d59563" }] }, { "featureType": "water", "elementType": "geometry", "stylers": [{ "color": "#17263c" }] }, { "featureType": "water", "elementType": "labels.text.fill", "stylers": [{ "color": "#515c6d" }] }, { "featureType": "water", "elementType": "labels.text.stroke", "stylers": [{ "color": "#17263c" }] }], 39 aubergine: [{ "elementType": "geometry", "stylers": [{ "color": "#1d2c4d" }] }, { "elementType": "labels.text.fill", "stylers": [{ "color": "#8ec3b9" }] }, { "elementType": "labels.text.stroke", "stylers": [{ "color": "#1a3646" }] }, { "featureType": "administrative.country", "elementType": "geometry.stroke", "stylers": [{ "color": "#4b6878" }] }, { "featureType": "administrative.land_parcel", "elementType": "labels.text.fill", "stylers": [{ "color": "#64779e" }] }, { "featureType": "administrative.province", "elementType": "geometry.stroke", "stylers": [{ "color": "#4b6878" }] }, { "featureType": "landscape.man_made", "elementType": "geometry.stroke", "stylers": [{ "color": "#334e87" }] }, { "featureType": "landscape.natural", "elementType": "geometry", "stylers": [{ "color": "#023e58" }] }, { "featureType": "poi", "elementType": "geometry", "stylers": [{ "color": "#283d6a" }] }, { "featureType": "poi", "elementType": "labels.text.fill", "stylers": [{ "color": "#6f9ba5" }] }, { "featureType": "poi", "elementType": "labels.text.stroke", "stylers": [{ "color": "#1d2c4d" }] }, { "featureType": "poi.park", "elementType": "geometry.fill", "stylers": [{ "color": "#023e58" }] }, { "featureType": "poi.park", "elementType": "labels.text.fill", "stylers": [{ "color": "#3C7680" }] }, { "featureType": "road", "elementType": "geometry", "stylers": [{ "color": "#304a7d" }] }, { "featureType": "road", "elementType": "labels.text.fill", "stylers": [{ "color": "#98a5be" }] }, { "featureType": "road", "elementType": "labels.text.stroke", "stylers": [{ "color": "#1d2c4d" }] }, { "featureType": "road.highway", "elementType": "geometry", "stylers": [{ "color": "#2c6675" }] }, { "featureType": "road.highway", "elementType": "geometry.stroke", "stylers": [{ "color": "#255763" }] }, { "featureType": "road.highway", "elementType": "labels.text.fill", "stylers": [{ "color": "#b0d5ce" }] }, { "featureType": "road.highway", "elementType": "labels.text.stroke", "stylers": [{ "color": "#023e58" }] }, { "featureType": "transit", "elementType": "labels.text.fill", "stylers": [{ "color": "#98a5be" }] }, { "featureType": "transit", "elementType": "labels.text.stroke", "stylers": [{ "color": "#1d2c4d" }] }, { "featureType": "transit.line", "elementType": "geometry.fill", "stylers": [{ "color": "#283d6a" }] }, { "featureType": "transit.station", "elementType": "geometry", "stylers": [{ "color": "#3a4762" }] }, { "featureType": "water", "elementType": "geometry", "stylers": [{ "color": "#0e1626" }] }, { "featureType": "water", "elementType": "labels.text.fill", "stylers": [{ "color": "#4e6d70" }] }] 40 }; 54 41 55 42 var mapController = []; … … 57 44 var geocoder = new google.maps.Geocoder; 58 45 var infowindow = new google.maps.InfoWindow; 59 var reInfowindow = new google.maps.InfoWindow( {60 pixelOffset: new google.maps.Size( 0, -40),61 } );46 var reInfowindow = new google.maps.InfoWindow({ 47 pixelOffset: new google.maps.Size(0, -40), 48 }); 62 49 63 50 // On load Ajax listing map. 64 jQuery( document ).ready( function( $) {51 jQuery(document).ready(function ($) { 65 52 imgSvg(); 66 53 ammSearch(); … … 71 58 createImageTags(); 72 59 73 // google.maps.event.addListener( infowindow, 'closeclick', function() { 74 // drawingManager.setDrawingMode( 'marker' ); 75 // } ); 76 77 $( '.color-field' ).wpColorPicker({ 78 change: function ( event, ui ) { 60 $('.color-field').wpColorPicker({ 61 change: function (event, ui) { 79 62 var element = event.target; 80 var color = hexToRgb( ui.color.toString());63 var color = hexToRgb(ui.color.toString()); 81 64 selectColor("rgb(" + color.r + "," + color.g + "," + color.b + ")"); 82 65 }, 83 66 }); 67 $('.color-box').on('click', function () { 68 const newColor = $(this).data('bgcolor'); 69 const hexObj = hexToRgb(newColor); 70 selectColor("rgb(" + hexObj.r + "," + hexObj.g + "," + hexObj.b + ")"); 71 $('button.wp-color-result').css('background-color', newColor); 72 $('.color-field').val(newColor); 73 }); 84 74 }); 85 75 86 function hexToRgb( hex) {76 function hexToRgb(hex) { 87 77 var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); 88 78 return result ? { 89 r: parseInt( result[1], 16),90 g: parseInt( result[2], 16),91 b: parseInt( result[3], 16)79 r: parseInt(result[1], 16), 80 g: parseInt(result[2], 16), 81 b: parseInt(result[3], 16) 92 82 } : null; 93 83 } 94 84 95 85 var markerData = amm_plugin_obj.amm_save_option; 96 if ( markerData.amm_marker_type) {97 var oldMapType = JSON.parse( markerData.amm_marker_type);98 var oldMapLatlngs = JSON.parse( markerData.amm_marker_positions);86 if (markerData.amm_marker_type && markerData.amm_marker_positions) { 87 var oldMapType = JSON.parse(markerData.amm_marker_type); 88 oldMapLatlngs = JSON.parse(markerData.amm_marker_positions); 99 89 } 100 90 // Map controller object. 101 if ( markerData.amm_map_control) {102 var mapControl = JSON.parse( markerData.amm_map_control);91 if (markerData.amm_map_control) { 92 var mapControl = JSON.parse(markerData.amm_map_control); 103 93 } 104 94 105 95 // Init map. 106 96 function init_map() { 107 var latlng = { 108 lat: ( markerData.amm_map_control ) ? mapControl[0].lat : 38.7520698, 109 lng: ( markerData.amm_map_control ) ? mapControl[0].lng : 33.3604434, 97 const mapFullScreenStatus = mapSettings.map_full_screen ? true : false; 98 const mapTypeControlStatus = mapSettings.map_type_control ? true : false; 99 const mapStreetViewStatus = mapSettings.map_street_view ? true : false; 100 const initialCenter = { 101 lat: (markerData.amm_map_control) ? mapControl[0].lat : 38.7520698, 102 lng: (markerData.amm_map_control) ? mapControl[0].lng : 33.3604434, 110 103 }; 104 111 105 // Init Map with current location. 112 map = new google.maps.Map( document.getElementById( 'amm-map' ), { 113 center: latlng, 114 zoom: ( markerData.amm_map_control ) ? mapControl[0].zoom : parseInt( amm_plugin_obj.map_settings.map_zoom ), 115 styles: selectedStyle, 116 mapTypeId: mapStyleType, 117 fullscreenControl: ( amm_plugin_obj.map_settings.map_full_screen ) ? true : false, 118 mapTypeControl: ( amm_plugin_obj.map_settings.map_type_control ) ? true : false, 119 streetViewControl: ( amm_plugin_obj.map_settings.map_street_view ) ? true : false, 120 } ); 121 106 map = new google.maps.Map(document.getElementById('amm-map'), { 107 center: initialCenter, 108 zoom: (markerData.amm_map_control) ? mapControl[0].zoom : parseInt(mapSettings.map_zoom), 109 mapId: 'amm-map', 110 mapTypeId: mapSettings.map_style, 111 navigationControl: true, 112 fullscreenControl: mapFullScreenStatus, 113 mapTypeControl: mapTypeControlStatus, 114 streetViewControl: mapStreetViewStatus, 115 }); 116 117 const styledMapType = new google.maps.StyledMapType( 118 mapStyles[mapStyleType], 119 { name: mapStyleType } 120 ); 121 122 map.mapTypes.set("custom_style", styledMapType); 123 map.setMapTypeId("custom_style"); 124 122 125 if (location.protocol == 'https:') { 123 if ( navigator.geolocation ) { 124 navigator.geolocation.getCurrentPosition( function( position ) { 125 var pos = { 126 lat: position.coords.latitude, 127 lng: position.coords.longitude 128 }; 129 }, 130 function () { 131 // Gelocation fallback: Defaults to Stockholm, Sweden 132 // markerText = "<p>Please accept geolocation for me to be able to find you. <br>I've put you in Stockholm for now.</p>"; 133 var pos = { 134 lat: 59.3325215, 135 lng: 18.0643818 136 }; 137 }); 138 } 139 }else{ 140 // No geolocation fallback: Defaults to USA 141 // markerText = "<p>No location support. Try USA for now. :-)</p>"; 142 var pos = { 143 lat: 39.218129, 144 lng: -97.855122 145 }; 146 } 147 map.setCenter( pos ); 148 map.setZoom( 5 ); 126 if (navigator.geolocation) { 127 navigator.geolocation.getCurrentPosition(function ({ coords }) { 128 map.setCenter({ 129 lat: coords.latitude, 130 lng: coords.longitude 131 }); 132 map.setZoom(5); 133 oldMapLatlngs.map(function (marker, i) { 134 if (marker.lat === coords.latitude && marker.lng === coords.longitude) { 135 currentLocation = coords; 136 document.getElementById('drop_marker_wrap').style.display = 'none'; 137 dropMarkerBtnState = false; 138 } 139 }); 140 }, 141 () => { 142 // Gelocation fallback: Defaults to Stockholm, Sweden 143 // markerText = "<p>Please accept geolocation for me to be able to find you. <br>I've put you in Stockholm for now.</p>"; 144 map.setCenter({ 145 lat: 59.3325215, 146 lng: 18.0643818 147 }); 148 map.setZoom(5); 149 }); 150 } 151 } else { 152 // No geolocation fallback: Defaults to USA 153 var pos = { 154 lat: 39.218129, 155 lng: -97.855122 156 }; 157 } 158 map.setCenter(pos); 159 map.setZoom(5); 149 160 150 161 // Shape array which helps to add all the shape in this array. 151 var markerArray = [];152 if ( oldMapLatlngs ) {162 if (oldMapLatlngs) { 163 const bounds = new google.maps.LatLngBounds(); 153 164 // Add map drawing tools. 154 oldMapLatlngs.forEach( function( latlg, i ) { 155 allDrawShape.push( i ); 156 markerArray.push( oldMapType[0].type[i] ); 165 oldMapLatlngs.forEach(function (latlg, i) { 166 const shapeType = oldMapType[0].type[i]; 167 let latlngs = {}; 168 169 allDrawShape.push(i); 170 markerArray.push(shapeType); 157 171 drawShapeDetail.push(oldMapLatlngs[i]); 158 172 var multipoint = []; 159 173 // MapType Marker. 160 if ( oldMapType[0].type[i] == 'marker') {161 var latlngs = { lat: parseFloat( latlg.lat ), lng: parseFloat( latlg.lng) };174 if ('marker' == shapeType) { 175 latlngs = { lat: parseFloat(latlg.lat), lng: parseFloat(latlg.lng) }; 162 176 // Init marker postion. 163 var saveShape = new google.maps.Marker( {177 var saveShape = new google.maps.Marker({ 164 178 position: latlngs, 165 179 map: map, 166 180 icon: latlg.img[0], 167 type: oldMapType[0].type[i], // Custom array to get the shape type.168 } );181 type: shapeType, 182 }); 169 183 // Open Infowindow. 170 google.maps.event.addListener( saveShape, 'dblclick', function(e) {171 cons ole.log(this.map);184 google.maps.event.addListener(saveShape, 'dblclick', function (e) { 185 const markerTitle = latlg.title || ''; 172 186 reInfowindow = new google.maps.InfoWindow({ 173 content: '<div ><strong>' + latlg.title[0] + '</strong><br /><a href="https://www.google.com/maps/search/?api=1&query=' + parseFloat( latlg.lat ) + ',' + parseFloat( latlg.lng) + '&query_place_id=' + latlg.place_id + '" target="_blank">Get Direction</a></div>',187 content: '<div style="max-width: 300px;"><strong>' + markerTitle + '</strong><br /><a href="https://www.google.com/maps/search/?api=1&query=' + parseFloat(latlg.lat) + ',' + parseFloat(latlg.lng) + '&query_place_id=' + latlg.place_id + '" target="_blank">Get Direction</a></div>', 174 188 }); 175 reInfowindow.open( map, saveShape);189 reInfowindow.open(map, saveShape); 176 190 }); 177 191 } 178 192 // oldMapType polygon & polyline. 179 if ( oldMapType[0].type[i] == 'polygon' || oldMapType[0].type[i] == 'polyline' ) { 180 latlg.poly.forEach( function( pos, j ) { 181 multipoint.push( pos ); 193 if ('polygon' == shapeType || 'polyline' == shapeType) { 194 latlg.poly.forEach(function (pos, j) { 195 multipoint.push(pos); 196 latlngs = { lat: parseFloat(pos.lat), lng: parseFloat(pos.lng) }; 197 bounds.extend(latlngs); 198 map.fitBounds(bounds); 182 199 }); 183 200 184 201 var triangleCoords = multipoint; 185 202 // Construct the polygon. 186 203 var saveShape = new google.maps.Polygon({ 187 204 paths: triangleCoords, 188 strokeColor: latlg.fillcolor, 205 strokeColor: latlg.fillcolor, 189 206 strokeOpacity: 0.8, 190 207 strokeWeight: 3, 191 208 fillColor: latlg.fillcolor, 192 209 fillOpacity: 0.35, 193 type: oldMapType[0].type[i], // Custom array to get the shape type.210 type: shapeType, 194 211 }); 195 saveShape.setMap( map);212 saveShape.setMap(map); 196 213 } 197 214 // oldMapType circle. 198 if ( oldMapType[0].type[i] == 'circle' ) { 215 if ('circle' == shapeType) { 216 latlngs = { lat: parseFloat(latlg.circle.lat), lng: parseFloat(latlg.circle.lng) }; 199 217 var saveShape = new google.maps.Circle({ 200 218 strokeColor: latlg.fillcolor, … … 206 224 center: latlg.circle, 207 225 radius: latlg.radius, 208 type: oldMapType[0].type[i], // Custom array to get the shape type.226 type: shapeType, 209 227 }); 228 bounds.extend(latlngs); 229 map.fitBounds(bounds); 210 230 } 211 231 // oldMapType rectangle. 212 if ( oldMapType[0].type[i] == 'rectangle' ) { 232 if ('rectangle' == shapeType) { 233 latlngs = { lat: parseFloat((latlg[shapeType].north + latlg[shapeType].south) / 2), lng: parseFloat((latlg[shapeType].east + latlg[shapeType].west) / 2) } 213 234 var saveShape = new google.maps.Rectangle({ 214 235 strokeColor: latlg.fillcolor, … … 219 240 map: map, 220 241 bounds: latlg.rectangle, 221 type: oldMapType[0].type[i], // Custom array to get the shape type.242 type: shapeType, 222 243 }); 223 244 bounds.extend(latlngs); 245 map.fitBounds(bounds); 224 246 } 225 247 // Remove save shape from map. 226 google.maps.event.addListener( saveShape, 'click', function(e) { 227 if ( oldMapLatlngs[i] ) { 228 removeSelectedDrawShape( oldMapLatlngs[i], oldMapType[0].type[i] ); 229 setDrawingShape( saveShape ); 230 } 231 }); 232 248 google.maps.event.addListener(saveShape, 'click', function (e) { 249 if (oldMapLatlngs[i]) { 250 removeSelectedDrawShape(oldMapLatlngs[i], shapeType); 251 setDrawingShape(saveShape); 252 } 253 }); 254 bounds.extend(latlngs); 255 map.fitBounds(bounds); 233 256 }); 234 // document.getElementById( 'amm_marker_type' ).value = JSON.stringify( oldMapType );235 // document.getElementById( 'amm_marker_positions' ).value = JSON.stringify( oldMapLatlngs );236 257 } 237 258 238 259 // if center changed then update lat and lon document objects 239 google.maps.event.addListener( map, 'center_changed', function () {260 google.maps.event.addListener(map, 'center_changed', function () { 240 261 var location = map.getCenter(); 241 262 mapController = []; 242 mapController.push( {lat: location.lat(), lng: location.lng(), zoom: map.zoom});243 document.getElementById('amm_map_control').value = JSON.stringify( mapController);263 mapController.push({ lat: location.lat(), lng: location.lng(), zoom: map.zoom }); 264 document.getElementById('amm_map_control').value = JSON.stringify(mapController); 244 265 }); 245 266 246 267 // Created variable for the drawing modes. 247 268 var polyOptions = { 248 strokeWeight: 0,249 fillOpacity: 0.6,250 editable: true,251 draggable: true,252 disableDoubleClickZoom: true269 strokeWeight: 0, 270 fillOpacity: 0.6, 271 editable: true, 272 draggable: true, 273 disableDoubleClickZoom: true 253 274 }; 254 275 //DrawingManager helps to create shapes/drawingMpdes on Maps. … … 261 282 }, 262 283 markerOptions: { 263 draggable: true284 draggable: true 264 285 }, 265 286 polylineOptions: { 266 editable: true,267 draggable: true287 editable: true, 288 draggable: true 268 289 }, 269 290 rectangleOptions: polyOptions, … … 275 296 // This is for storing map date into database. 276 297 // When draw of overlay complete. 277 google.maps.event.addListener( drawingManager, 'overlaycomplete', function( event) {278 varsubmitMap = document.getElementById('amm-maps-submit');298 google.maps.event.addListener(drawingManager, 'overlaycomplete', function (event) { 299 const submitMap = document.getElementById('amm-maps-submit'); 279 300 if (submitMap.disabled == true) { 280 301 submitMap.disabled = false; … … 282 303 document.getElementById('amm-maps-submit').disabled = false; 283 304 // Stop zoom when dbclick on map marker or shapes. 284 map.setOptions( {disableDoubleClickZoom: true });305 map.setOptions({ disableDoubleClickZoom: true }); 285 306 // Each overlay index. 286 307 var mapIndex = allDrawShape.length; … … 288 309 drawShape = event.overlay; 289 310 drawShape.type = event.type; 311 drawShape.uuid = Date.now(); 290 312 291 313 // Drawing shape is marker. 292 if ( drawShape.type === 'marker') {314 if (drawShape.type === 'marker') { 293 315 // Push marker detail in drawShapeDetail object with blank title. 294 drawShapeDetail.push( {lat: drawShape.getPosition().lat(), lng: drawShape.getPosition().lng(), img: [drawShape.icon], title: '', place_id: ''} ); 316 drawShapeDetail.push({ uuid: drawShape.uuid, lat: drawShape.getPosition().lat(), lng: drawShape.getPosition().lng(), img: [drawShape.icon], title: '', place_id: '' }); 317 markerPositionsInput.value = JSON.stringify(drawShapeDetail); 295 318 // When push marker on map infowindow opens with custom label and you can edit it.. 296 var latlng = {lat: parseFloat(drawShape.getPosition().lat()), lng: parseFloat(drawShape.getPosition().lng())}; 297 geocoder.geocode( {'location': latlng}, function( results, status ) { 298 if ( status === 'OK' ) { 299 if ( results[0] ) { 300 infowindow.setContent( '<div id="map-popup"><textarea rows="2" cols="30" id="map-info_' + mapIndex + '" placeholder="Add your label here..."></textarea></div>' ); 301 infowindow.open( map, drawShape ); 302 drawShapeDetail[mapIndex].place_id = results[1].place_id; 303 document.getElementById('amm_marker_positions').value = JSON.stringify( drawShapeDetail ); 304 } else { 305 window.alert( 'No results found where you have clicked' ); 306 } 307 } 308 }); 309 310 markerArray.push( drawShape.type ); 319 var latlng = { lat: parseFloat(drawShape.getPosition().lat()), lng: parseFloat(drawShape.getPosition().lng()) }; 320 geocoder.geocode({ 'location': latlng }, function (results, status) { 321 if (status === 'OK' && results && results.length) { 322 var primaryResult = results[0]; 323 infowindow.setContent('<div id="map-popup"><textarea rows="2" cols="30" id="map-info_' + mapIndex + '" placeholder="Add your label here..."></textarea></div>'); 324 infowindow.open(map, drawShape); 325 drawShapeDetail[mapIndex].place_id = primaryResult.place_id || ''; 326 markerPositionsInput.value = JSON.stringify(drawShapeDetail); 327 } else if (status === 'ZERO_RESULTS') { 328 window.alert('No results found where you have clicked'); 329 } 330 }); 331 332 markerArray.push(drawShape.type); 311 333 // Add value to input fields. 312 document.getElementById('amm_marker_type').value = JSON.stringify( mapType);313 314 allDrawShape.push( drawShape);334 markerTypeInput.value = JSON.stringify(mapType); 335 336 allDrawShape.push(drawShape); 315 337 316 338 // Remove selected option from drawing tools. 317 drawingManager.setDrawingMode( null);339 drawingManager.setDrawingMode(null); 318 340 319 341 // Popup info window. 320 drawShape.addListener( 'dblclick', markerInfoWindow);342 drawShape.addListener('dblclick', markerInfoWindow); 321 343 322 344 // Update lng and lat when drag the marker from one place to other place. 323 google.maps.event.addListener( drawShape, 'dragend', function( markerPos ) { 324 var markerIndex = allDrawShape.indexOf( this ); 325 if ( drawShapeDetail ) { 326 var latlng = {lat: parseFloat(markerPos.latLng.lat()), lng: parseFloat(markerPos.latLng.lng())}; 327 geocoder.geocode( {'location': latlng}, function( results, status ) { 328 if ( status === 'OK' ) { 329 if ( results[0] ) { 330 reInfowindow.setContent( '<div id="map-popup"><textarea rows="2" cols="30" id="map-info_' + markerIndex + '" placeholder="Add your label here..."></textarea></div>' ); 331 reInfowindow.setPosition( markerPos.latLng ); 332 reInfowindow.open( map ); 333 // Update title, lan, and lat. 334 drawShapeDetail[markerIndex].lat = results[0].geometry.location.lat(); 335 drawShapeDetail[markerIndex].lng = results[0].geometry.location.lng(); 336 drawShapeDetail[mapIndex].place_id = results[1].place_id; 337 document.getElementById('amm_marker_positions').value = JSON.stringify( drawShapeDetail ); 338 // Function calling for the input title on popup. 339 infoWindowTItle( markerIndex ); 340 } else { 341 window.alert( 'No results found where you have dragend' ); 342 } 343 } 344 }); 345 } 346 }); 345 markerDragHandler(drawShape); 347 346 // Calling function for updating map title. 348 infoWindowT Itle( mapIndex);347 infoWindowTitle(mapIndex); 349 348 } 350 349 351 350 // Drawing shape is "Circle". 352 if ( drawShape.type === 'circle') {351 if (drawShape.type === 'circle') { 353 352 // Push circle detail in drawShapeDetail object with blank title. 354 drawShapeDetail.push( {circle: drawShape.getCenter(), radius: drawShape.getRadius(), fillcolor: drawShape.fillColor});353 drawShapeDetail.push({ uuid: drawShape.uuid, circle: drawShape.getCenter(), radius: drawShape.getRadius(), fillcolor: drawShape.fillColor }); 355 354 // On drawing circle label option. 356 infowindow.setPosition( drawShape.getCenter());355 infowindow.setPosition(drawShape.getCenter()); 357 356 358 357 // Remove selected option from drawing tools. 359 drawingManager.setDrawingMode( null);360 361 markerArray.push( drawShape.type);358 drawingManager.setDrawingMode(null); 359 360 markerArray.push(drawShape.type); 362 361 363 362 // Added value in hidden fields. 364 document.getElementById('amm_marker_type').value = JSON.stringify( mapType);365 document.getElementById('amm_marker_positions').value = JSON.stringify( drawShapeDetail);366 367 allDrawShape.push( drawShape);363 markerTypeInput.value = JSON.stringify(mapType); 364 markerPositionsInput.value = JSON.stringify(drawShapeDetail); 365 366 allDrawShape.push(drawShape); 368 367 369 368 // On change shape. 370 drawShape.addListener('bounds_changed', function () {371 var markerIndex = allDrawShape.indexOf( this);369 drawShape.addListener('bounds_changed', function () { 370 var markerIndex = allDrawShape.indexOf(this); 372 371 drawShapeDetail[markerIndex].circle = this.getCenter(); 373 372 drawShapeDetail[markerIndex].radius = this.getRadius(); 374 document.getElementById('amm_marker_positions').value = JSON.stringify( drawShapeDetail);373 markerPositionsInput.value = JSON.stringify(drawShapeDetail); 375 374 }); 376 375 } 377 376 378 377 // Drawing shape are "Polyline" & "Polygon". 379 if ( drawShape.type === 'polygon' || drawShape.type == 'polyline') {378 if (drawShape.type === 'polygon' || drawShape.type == 'polyline') { 380 379 var polygonLatLng = []; 381 if ( drawShape.type === 'polygon') {380 if (drawShape.type === 'polygon') { 382 381 var polycolor = drawShape.fillColor; 383 382 } … … 387 386 388 387 var polygonLenght = drawShape.getPath().getLength(); 389 for ( var i = 0; i < polygonLenght; i++) {390 polygonLatLng.push( drawShape.getPath().getAt(i));388 for (var i = 0; i < polygonLenght; i++) { 389 polygonLatLng.push(drawShape.getPath().getAt(i)); 391 390 } 392 391 // Push polygon detail in drawShapeDetail object with blank title. 393 drawShapeDetail.push( { poly: polygonLatLng, fillcolor: polycolor});394 // On drawing circle label option.395 infowindow.setPosition( drawShape.getPath().getAt(0));392 drawShapeDetail.push({ uuid: drawShape.uuid, poly: polygonLatLng, fillcolor: polycolor }); 393 // On drawing circle label option. 394 infowindow.setPosition(drawShape.getPath().getAt(0)); 396 395 397 396 // Remove selected option from drawing tools. 398 drawingManager.setDrawingMode( null);399 400 markerArray.push( drawShape.type);401 402 document.getElementById('amm_marker_type').value = JSON.stringify( mapType);403 document.getElementById('amm_marker_positions').value = JSON.stringify( drawShapeDetail);404 405 allDrawShape.push( drawShape);397 drawingManager.setDrawingMode(null); 398 399 markerArray.push(drawShape.type); 400 401 markerTypeInput.value = JSON.stringify(mapType); 402 markerPositionsInput.value = JSON.stringify(drawShapeDetail); 403 404 allDrawShape.push(drawShape); 406 405 407 406 // Declare array. 408 407 var polyInsertLatLng = []; 409 408 // Insert new point with lat and lng. 410 drawShape.getPath().addListener( 'insert_at', function() {411 var markerIndex = allDrawShape.indexOf( drawShape);409 drawShape.getPath().addListener('insert_at', function () { 410 var markerIndex = allDrawShape.indexOf(drawShape); 412 411 413 412 var polyInsertLenght = this.length; 414 for ( var j = 0; j < polyInsertLenght; j++) {415 polyInsertLatLng.push( this.getAt(j));413 for (var j = 0; j < polyInsertLenght; j++) { 414 polyInsertLatLng.push(this.getAt(j)); 416 415 } 417 416 418 417 drawShapeDetail[markerIndex].poly = polyInsertLatLng; 419 document.getElementById('amm_marker_positions').value = JSON.stringify( drawShapeDetail);418 markerPositionsInput.value = JSON.stringify(drawShapeDetail); 420 419 }); 421 420 … … 423 422 var polySetLatLng = [] 424 423 // Update exiting poly lat and lng. 425 drawShape.getPath().addListener( 'set_at', function() {426 var markerIndex = allDrawShape.indexOf( drawShape);424 drawShape.getPath().addListener('set_at', function () { 425 var markerIndex = allDrawShape.indexOf(drawShape); 427 426 428 427 var polySetLenght = this.length; 429 for ( var k = 0; k < polySetLenght; k++) {430 polySetLatLng.push( this.getAt(k));428 for (var k = 0; k < polySetLenght; k++) { 429 polySetLatLng.push(this.getAt(k)); 431 430 } 432 431 drawShapeDetail[markerIndex].poly = polySetLatLng; 433 document.getElementById('amm_marker_positions').value = JSON.stringify( drawShapeDetail);432 markerPositionsInput.value = JSON.stringify(drawShapeDetail); 434 433 }); 435 434 } 436 435 437 436 // Drawing shape is "Rectangle". 438 if ( drawShape.type === 'rectangle') {437 if (drawShape.type === 'rectangle') { 439 438 // Push rectangle detail in drawShapeDetail object with blank title. 440 drawShapeDetail.push( {rectangle: drawShape.getBounds(), fillcolor: drawShape.fillColor});439 drawShapeDetail.push({ uuid: drawShape.uuid, rectangle: drawShape.getBounds(), fillcolor: drawShape.fillColor }); 441 440 // On drawing circle label option. 442 infowindow.setPosition( drawShape.getBounds().getNorthEast());441 infowindow.setPosition(drawShape.getBounds().getNorthEast()); 443 442 444 443 // Remove selected option from drawing tools. 445 drawingManager.setDrawingMode( null);444 drawingManager.setDrawingMode(null); 446 445 447 446 markerArray.push(drawShape.type); 448 447 449 document.getElementById('amm_marker_type').value = JSON.stringify( mapType);450 document.getElementById('amm_marker_positions').value = JSON.stringify( drawShapeDetail);451 452 allDrawShape.push( drawShape);448 markerTypeInput.value = JSON.stringify(mapType); 449 markerPositionsInput.value = JSON.stringify(drawShapeDetail); 450 451 allDrawShape.push(drawShape); 453 452 // Bounds change for the rectangle. 454 drawShape.addListener('bounds_changed', function () {455 var markerIndex = allDrawShape.indexOf( this);453 drawShape.addListener('bounds_changed', function () { 454 var markerIndex = allDrawShape.indexOf(this); 456 455 drawShapeDetail[markerIndex].rectangle = this.getBounds(); 457 document.getElementById('amm_marker_positions').value = JSON.stringify( drawShapeDetail);456 markerPositionsInput.value = JSON.stringify(drawShapeDetail); 458 457 459 458 }); … … 461 460 462 461 // Remove selected marker. 463 if ( drawShape.type !== google.maps.drawing.OverlayType.MARKER) {462 if (drawShape.type !== google.maps.drawing.OverlayType.MARKER) { 464 463 // Switch back to non-drawing mode after drawing a shape. 465 drawingManager.setDrawingMode( null);464 drawingManager.setDrawingMode(null); 466 465 467 466 // Click event for all the shape which we draw. 468 google.maps.event.addListener( drawShape, 'click', function(e) {467 google.maps.event.addListener(drawShape, 'click', function (e) { 469 468 // For removing the arrays. 470 var index = allDrawShape.indexOf( this);469 var index = allDrawShape.indexOf(this); 471 470 472 471 if (drawShapeDetail[index]) { 473 removeSelectedDrawShape( drawShapeDetail[index], mapType[0].type[index]);472 removeSelectedDrawShape(drawShapeDetail[index], mapType[0].type[index]); 474 473 } 475 474 else { 476 removeSelectedDrawShape( drawShape, drawShape.type);475 removeSelectedDrawShape(drawShape, drawShape.type); 477 476 } 478 477 // After creating map or adding shape. Drawingshape will make setnull. 479 if ( event.vertex !== undefined) {480 if ( drawShape.type === google.maps.drawing.OverlayType.POLYGON) {481 var path = drawShape.getPaths().getAt( e.path);482 path.removeAt( e.vertex);483 if ( path.length < 3) {484 drawShape.setMap( null);478 if (event.vertex !== undefined) { 479 if (drawShape.type === google.maps.drawing.OverlayType.POLYGON) { 480 var path = drawShape.getPaths().getAt(e.path); 481 path.removeAt(e.vertex); 482 if (path.length < 3) { 483 drawShape.setMap(null); 485 484 } 486 485 } 487 if ( drawShape.type === google.maps.drawing.OverlayType.POLYLINE) {486 if (drawShape.type === google.maps.drawing.OverlayType.POLYLINE) { 488 487 var path = drawShape.getPath(); 489 488 path.removeAt(e.vertex); 490 if ( path.length < 2) {491 drawShape.setMap( null);489 if (path.length < 2) { 490 drawShape.setMap(null); 492 491 } 493 492 } 494 493 } 495 494 // Select drawing shape. 496 setDrawingShape( this);495 setDrawingShape(this); 497 496 }); 498 497 // Select drawing shape. 499 setDrawingShape( drawShape);498 setDrawingShape(drawShape); 500 499 } else { 501 google.maps.event.addListener( drawShape, 'click', function( e) {500 google.maps.event.addListener(drawShape, 'click', function (e) { 502 501 // For removing the arrays. 503 var index = allDrawShape.indexOf( this);504 505 if ( drawShapeDetail[index]) {506 removeSelectedDrawShape( drawShapeDetail[index], mapType[0].type[index]);502 var index = allDrawShape.indexOf(this); 503 504 if (drawShapeDetail[index]) { 505 removeSelectedDrawShape(drawShapeDetail[index], mapType[0].type[index]); 507 506 } 508 507 else { 509 removeSelectedDrawShape( drawShape, drawShape.type);508 removeSelectedDrawShape(drawShape, drawShape.type); 510 509 } 511 510 // Select drawing shape. 512 setDrawingShape( this);511 setDrawingShape(this); 513 512 }); 514 513 // Select drawing shape. 515 setDrawingShape( drawShape);514 setDrawingShape(drawShape); 516 515 } 517 516 518 517 }); 519 518 // Add all the shapes into the map. 520 drawingManager.setMap( map);519 drawingManager.setMap(map); 521 520 // Store all the shapes type in single array. 522 mapType.push( {type : markerArray});521 mapType.push({ type: markerArray }); 523 522 //Call map initialize. 524 523 init_auto(); … … 528 527 function init_auto() { 529 528 var inputs = document.getElementById('amm_search_area'); 530 if ( inputs) {531 var searchBox = new google.maps.places.SearchBox( inputs);532 map.addListener('bounds_changed', function () {533 searchBox.setBounds( map.getBounds());529 if (inputs) { 530 var searchBox = new google.maps.places.SearchBox(inputs); 531 map.addListener('bounds_changed', function () { 532 searchBox.setBounds(map.getBounds()); 534 533 }); 535 534 var markers = []; 536 535 // Listen for the event fired when the user selects a prediction and retrieve 537 536 // more details for that place. 538 searchBox.addListener('places_changed', function () {537 searchBox.addListener('places_changed', function () { 539 538 var places = searchBox.getPlaces(); 540 if ( places.length == 0) {539 if (places.length == 0) { 541 540 return; 542 541 } 543 542 // Clear out the old markers. 544 markers.forEach( function(marker) {545 marker.setMap( null);543 markers.forEach(function (marker) { 544 marker.setMap(null); 546 545 }); 547 546 … … 550 549 var bounds = new google.maps.LatLngBounds(); 551 550 552 places.forEach( function(place) {553 if ( !place.geometry) {554 console.log( 'Returned place contains no geometry');551 places.forEach(function (place) { 552 if (!place.geometry) { 553 console.log('Returned place contains no geometry'); 555 554 return; 556 555 } … … 558 557 var icon = { 559 558 url: place.icon, 560 size: new google.maps.Size( 71, 71),561 origin: new google.maps.Point( 0, 0),562 anchor: new google.maps.Point( 17, 34),563 scaledSize: new google.maps.Size( 25, 25)559 size: new google.maps.Size(71, 71), 560 origin: new google.maps.Point(0, 0), 561 anchor: new google.maps.Point(17, 34), 562 scaledSize: new google.maps.Size(25, 25) 564 563 }; 565 564 … … 573 572 }); 574 573 // Added positions into the map. 575 markers.push( positions);576 577 if ( place.geometry.viewport) {574 markers.push(positions); 575 576 if (place.geometry.viewport) { 578 577 // Only geocodes have viewport. 579 bounds.union( place.geometry.viewport);578 bounds.union(place.geometry.viewport); 580 579 } else { 581 bounds.extend( place.geometry.location);582 } 583 }); 584 map.fitBounds( bounds);580 bounds.extend(place.geometry.location); 581 } 582 }); 583 map.fitBounds(bounds); 585 584 }); 586 585 } 587 google.maps.event.addListener( drawingManager, 'drawingmode_changed', clearSelection);588 google.maps.event.addDomListener( document.getElementById('delete-shape'), 'click', deleteSelectedShapes);586 google.maps.event.addListener(drawingManager, 'drawingmode_changed', clearSelection); 587 google.maps.event.addDomListener(document.getElementById('delete-shape'), 'click', deleteSelectedShapes); 589 588 } 590 589 591 590 // On input (changes shape info) store value in shape array. 592 function infoWindowT Itle( i) {591 function infoWindowTitle(index) { 593 592 var mapTitle = []; 594 593 var timer; 595 var popupId = 'map-info_' + i; 596 setTimeout( function() { 597 document.getElementById( popupId ).addEventListener( 'input', function( e ) { 598 var thisTitle = this.value; 599 clearTimeout( timer ); 600 timer = setTimeout( function() { 601 mapTitle = []; 602 mapTitle.push( thisTitle ); 603 drawShapeDetail[i].title = mapTitle; 604 document.getElementById( 'amm_marker_positions' ).value = JSON.stringify( drawShapeDetail ); 605 }, 500 ); 606 } ); 607 }, 800 ); 594 var popupId = 'map-info_' + index; 595 setTimeout(function () { 596 let popup = document.getElementById(popupId); 597 if (popup) { 598 popup.addEventListener('input', function (e) { 599 var thisTitle = e.target.value; 600 clearTimeout(timer); 601 timer = setTimeout(function () { 602 mapTitle = []; 603 mapTitle.push(thisTitle); 604 drawShapeDetail[index]['title'] = thisTitle; 605 markerPositionsInput.value = JSON.stringify(drawShapeDetail); 606 }, 500); 607 }); 608 } 609 }, 500); 608 610 } 609 611 610 612 // Markee Information Window. 611 function markerInfoWindow( marker ) { 612 var markerIndex = allDrawShape.indexOf( this ); 613 function markerInfoWindow(marker) { 614 var markerIndex = allDrawShape.indexOf(this); 615 const latlng = { lat: parseFloat(drawShapeDetail[markerIndex].lat), lng: parseFloat(drawShapeDetail[markerIndex].lng) }; 616 613 617 // Content String on Popup. 614 if ( drawShapeDetail[markerIndex].title[0] != '') {615 var contentString = '<b>Title: ' + drawShapeDetail[markerIndex].title[0] + '</b>';616 reInfowindow.setContent( contentString );617 reInfowindow.set Position( marker.latLng);618 // Open Infowindow popup.619 reInfowindow.open( map);618 if (drawShapeDetail[markerIndex].title != '') { 619 const markerTitle = drawShapeDetail[markerIndex].title; 620 var contentString = '<div style="max-width: 300px;"><strong style="display:block; padding:5px;">Title: ' + markerTitle + '</strong><a href="https://www.google.com/maps/search/?api=1&query=' + parseFloat(drawShapeDetail[markerIndex].lat) + ',' + parseFloat(drawShapeDetail[markerIndex].lng) + '&query_place_id=' + drawShapeDetail[markerIndex].place_id + '" style="display:block; padding:5px;"" target="_blank">Get Direction</a></div>'; 621 reInfowindow.setContent(contentString); 622 reInfowindow.setPosition(latlng); 623 reInfowindow.open(map); 620 624 } 621 625 else { 622 reInfowindow.setContent( '<div id="map-popup"><textarea rows="2" cols="30" id="map-info_' + markerIndex + '" placeholder="Add your label here..."></textarea></div>' ); 623 infoWindowTItle( markerIndex ); 624 reInfowindow.setPosition( marker.latLng ); 625 reInfowindow.open( map ); 626 reInfowindow.setContent('<div id="map-popup" style="max-width: 300px;"><textarea rows="2" cols="30" id="map-info_' + markerIndex + '" placeholder="Add your label here..."></textarea></div>'); 627 setTimeout(() => { 628 infoWindowTitle(markerIndex); 629 }, 100); 630 reInfowindow.setPosition(latlng); 631 reInfowindow.open(map); 626 632 } 627 633 } 628 634 629 635 // On click Or On drawing shape select. 630 function setDrawingShape( shape) {636 function setDrawingShape(shape) { 631 637 var submitMap = document.getElementById('amm-maps-submit'); 632 638 if (submitMap.disabled == true) { … … 634 640 } 635 641 // Checking drawing shape type. 636 if ( shape.type !== 'marker') {642 if (shape.type !== 'marker') { 637 643 clearSelection(); 638 shape.setEditable( true);639 selectColor( shape.get( 'fillColor' ) || shape.get( 'strokeColor' ));644 shape.setEditable(true); 645 selectColor(shape.get('fillColor') || shape.get('strokeColor')); 640 646 } 641 647 // Add marker object in selectedShape variable. … … 646 652 function clearSelection() { 647 653 // When click on map marker/shape. 648 if ( selectedShape) {649 if ( selectedShape.type !== 'marker') {650 selectedShape.setEditable( false);654 if (selectedShape) { 655 if (selectedShape.type !== 'marker') { 656 selectedShape.setEditable(false); 651 657 } 652 658 selectedShape = null; … … 655 661 656 662 // Assign value to global variables. 657 function removeSelectedDrawShape( drawShape, shapeType) {663 function removeSelectedDrawShape(drawShape, shapeType) { 658 664 // Checking "drawShapeDetail" has drawShape.. 659 if ( drawShapeDetail) {665 if (drawShapeDetail) { 660 666 selectedShapeEle = []; 661 selectedShapeEle.push( { shape: drawShape, type: shapeType } ); 662 } 663 } 664 665 // Delete shape when click on delete button. 667 selectedShapeEle.push({ shape: drawShape, type: shapeType }); 668 } 669 } 670 671 /** 672 * Remove selected shapes. 673 * Delete shape when click on delete button 674 */ 666 675 function deleteSelectedShapes() { 667 // Remove select shapes. 668 if ( selectedShape ) { 669 selectedShape.setMap( null ); 676 if (selectedShape) { 677 selectedShape.setMap(null); 670 678 } 671 679 // Checking selected shape is not null. 672 if ( selectedShapeEle != '' ) { 673 if ( selectedShapeEle[0].shape ) { 674 var shapeKey = drawShapeDetail.indexOf( selectedShapeEle[0].shape ); 675 drawShapeDetail.splice( shapeKey, 1 ); 676 allDrawShape.splice( shapeKey, 1 ); 677 mapType[0].type.splice( shapeKey, 1 ); 678 } 679 selectedShapeEle = []; 680 } 681 document.getElementById( 'amm_marker_type' ).value = JSON.stringify( mapType ); 682 document.getElementById( 'amm_marker_positions' ).value = JSON.stringify( drawShapeDetail ); 680 if (selectedShape.getPosition().lat() === currentLocation.latitude && 681 selectedShape.getPosition().lng() === currentLocation.longitude) { 682 document.getElementById('drop_marker_wrap').style.display = 'block'; 683 dropMarkerBtnState = true; 684 } 685 if (selectedShape['uuid']) { 686 drawShapeDetail.forEach((s, i) => { 687 if (s['uuid'] === selectedShape['uuid']) { 688 drawShapeDetail.splice(i, 1); 689 allDrawShape.splice(i, 1); 690 mapType[0].type.splice(i, 1); 691 } 692 }); 693 } else { 694 var shapeKey = drawShapeDetail.indexOf(selectedShapeEle[0].shape); 695 drawShapeDetail.splice(shapeKey, 1); 696 allDrawShape.splice(shapeKey, 1); 697 mapType[0].type.splice(shapeKey, 1); 698 } 699 700 markerTypeInput.value = JSON.stringify(mapType); 701 markerPositionsInput.value = JSON.stringify(drawShapeDetail); 683 702 } 684 703 685 704 // Marker Images. 686 function selectImages( selectImg) {687 for ( var i = 0; i < markerImg.length; ++i) {705 function selectImages(selectImg) { 706 for (var i = 0; i < markerImg.length; ++i) { 688 707 var currImg = markerImg[i]; 689 708 imagesBtn[currImg].style.border = currImg == selectImg ? '2px solid #789' : '2px solid #fff'; 690 709 } 691 var markerOptions = drawingManager.get( 'markerOptions');710 var markerOptions = drawingManager.get('markerOptions'); 692 711 markerOptions.icon = selectImg; 693 drawingManager.set( 'markerOptions', markerOptions);694 } 695 696 function createImages( imageSrc) {697 var imgTags = document.createElement( 'img');712 drawingManager.set('markerOptions', markerOptions); 713 } 714 715 function createImages(imageSrc) { 716 var imgTags = document.createElement('img'); 698 717 imgTags.className = 'map-images'; 699 718 imgTags.src = imageSrc; 700 719 // Click for selecting google maps icons. 701 google.maps.event.addDomListener( imgTags, 'click', function () {702 selectImages( imageSrc);720 google.maps.event.addDomListener(imgTags, 'click', function () { 721 selectImages(imageSrc); 703 722 }); 704 723 return imgTags; … … 706 725 707 726 function createImageTags() { 708 var imagesTags = document.getElementById( 'amm-marker-imgs');709 for ( var i = 0; i < markerImg.length; ++i) {727 var imagesTags = document.getElementById('amm-marker-imgs'); 728 for (var i = 0; i < markerImg.length; ++i) { 710 729 var currImage = markerImg[i]; 711 var markerTags = createImages( currImage);712 imagesTags.appendChild( markerTags);730 var markerTags = createImages(currImage); 731 imagesTags.appendChild(markerTags); 713 732 imagesBtn[currImage] = markerTags; 714 733 } 715 selectImages( markerImg[0]);716 document.querySelectorAll( 'img.map-images' ).forEach( function( el) {717 wrap( el, document.createElement( 'div' ));718 }); 719 } 720 721 function wrap( el, wrapper) {722 el.parentNode.insertBefore( wrapper, el);723 wrapper.appendChild( el);734 selectImages(markerImg[0]); 735 document.querySelectorAll('img.map-images').forEach(function (el) { 736 wrap(el, document.createElement('div')); 737 }); 738 } 739 740 function wrap(el, wrapper) { 741 el.parentNode.insertBefore(wrapper, el); 742 wrapper.appendChild(el); 724 743 } 725 744 726 745 // Drawing tools shape colors. 727 function selectColor( color) {746 function selectColor(color) { 728 747 selectedColor = color; 729 748 730 var polylineOptions = drawingManager.get( 'polylineOptions');749 var polylineOptions = drawingManager.get('polylineOptions'); 731 750 polylineOptions.strokeColor = color; 732 drawingManager.set( 'polylineOptions', polylineOptions);733 734 var rectangleOptions = drawingManager.get( 'rectangleOptions');751 drawingManager.set('polylineOptions', polylineOptions); 752 753 var rectangleOptions = drawingManager.get('rectangleOptions'); 735 754 rectangleOptions.fillColor = color; 736 drawingManager.set( 'rectangleOptions', rectangleOptions);737 738 var circleOptions = drawingManager.get( 'circleOptions');755 drawingManager.set('rectangleOptions', rectangleOptions); 756 757 var circleOptions = drawingManager.get('circleOptions'); 739 758 circleOptions.fillColor = color; 740 drawingManager.set( 'circleOptions', circleOptions);741 742 var polygonOptions = drawingManager.get( 'polygonOptions');759 drawingManager.set('circleOptions', circleOptions); 760 761 var polygonOptions = drawingManager.get('polygonOptions'); 743 762 polygonOptions.fillColor = color; 744 drawingManager.set( 'polygonOptions', polygonOptions ); 745 } 746 747 // SVG icon. 763 drawingManager.set('polygonOptions', polygonOptions); 764 } 765 766 /** 767 * replaces the <img> tag with the parsed <svg>. 768 */ 748 769 function imgSvg() { 749 jQuery( '.imgsvg' ).each( function() {750 var $img = jQuery( this);751 var imgID = $img.attr( 'id');752 var imgClass = $img.attr( 'class');753 var imgURL = $img.attr( 'src');754 jQuery.get( imgURL, function( data) {755 var $svg = jQuery(data).find( 'svg');756 if ( typeof imgID !== 'undefined') {757 $svg = $svg.attr( 'id', imgID);758 } 759 if ( typeof imgClass !== 'undefined') {760 $svg = $svg.attr( 'class', imgClass + ' replaced-svg');761 } 762 $svg = $svg.removeAttr( 'xmlns:a');763 if ( ! $svg.attr( 'viewBox' ) && $svg.attr( 'height' ) && $svg.attr( 'width' )) {764 $svg.attr( 'viewBox', '0 0 ' + $svg.attr( 'height' ) + ' ' + $svg.attr( 'width' ))765 } 766 $img.replaceWith( $svg);767 }, 'xml' );768 } );770 jQuery('.imgsvg').each(function () { 771 var $img = jQuery(this); 772 var imgID = $img.attr('id'); 773 var imgClass = $img.attr('class'); 774 var imgURL = $img.attr('src'); 775 jQuery.get(imgURL, function (data) { 776 var $svg = jQuery(data).find('svg'); 777 if (typeof imgID !== 'undefined') { 778 $svg = $svg.attr('id', imgID); 779 } 780 if (typeof imgClass !== 'undefined') { 781 $svg = $svg.attr('class', imgClass + ' replaced-svg'); 782 } 783 $svg = $svg.removeAttr('xmlns:a'); 784 if (!$svg.attr('viewBox') && $svg.attr('height') && $svg.attr('width')) { 785 $svg.attr('viewBox', '0 0 ' + $svg.attr('height') + ' ' + $svg.attr('width')) 786 } 787 $img.replaceWith($svg); 788 }, 'xml'); 789 }); 769 790 } 770 791 771 792 // Search show and hide. 772 793 function ammSearch() { 773 jQuery( '.amm-search-action a' ).click( function() {774 jQuery( '.amm-map-search-bar').fadeIn();775 } );776 jQuery( '.search-close' ).click( function() {777 jQuery( '.amm-map-search-bar').fadeOut();778 jQuery( '#amm_search_area').val('');779 } );780 jQuery( '.sidebar-action, .amm-sidebar-close' ).click( function() {781 jQuery( '.amm-map-header' ).toggleClass( 'full');782 jQuery( '.amm-map-content' ).toggleClass( 'full');783 jQuery( '.amm-map-sidebar' ).toggleClass( 'off');784 } );794 jQuery('.amm-search-action a').click(function () { 795 jQuery('.amm-map-search-bar').fadeIn(); 796 }); 797 jQuery('.search-close').click(function () { 798 jQuery('.amm-map-search-bar').fadeOut(); 799 jQuery('#amm_search_area').val(''); 800 }); 801 jQuery('.sidebar-action, .amm-sidebar-close').click(function () { 802 jQuery('.amm-map-header').toggleClass('full'); 803 jQuery('.amm-map-content').toggleClass('full'); 804 jQuery('.amm-map-sidebar').toggleClass('off'); 805 }); 785 806 } 786 807 787 808 // Map structure when responsiveness. 788 function mapStructure() {789 var ww = jQuery( window).width();790 if ( ww < 1500) {791 jQuery( '.amm-map-header' ).addClass( 'full');792 jQuery( '.amm-map-content' ).addClass( 'full');793 jQuery( '.amm-map-sidebar' ).addClass( 'off');809 function mapStructure() { 810 var ww = jQuery(window).width(); 811 if (ww < 1500) { 812 jQuery('.amm-map-header').addClass('full'); 813 jQuery('.amm-map-content').addClass('full'); 814 jQuery('.amm-map-sidebar').addClass('off'); 794 815 } else { 795 jQuery( '.amm-map-header' ).removeClass( 'full' ); 796 jQuery( '.amm-map-content' ).removeClass( 'full' ); 797 jQuery( '.amm-map-sidebar' ).removeClass( 'off' ); 798 } 816 jQuery('.amm-map-header').removeClass('full'); 817 jQuery('.amm-map-content').removeClass('full'); 818 jQuery('.amm-map-sidebar').removeClass('off'); 819 } 820 } 821 822 /** 823 * Handle marker drag. 824 */ 825 function markerDragHandler(marker) { 826 google.maps.event.addListener(marker, 'dragend', function (markerPos) { 827 var markerIndex = allDrawShape.indexOf(this); 828 if (drawShapeDetail) { 829 var latlng = { lat: parseFloat(markerPos.latLng.lat()), lng: parseFloat(markerPos.latLng.lng()) }; 830 drawShapeDetail[markerIndex].lat = latlng.lat; 831 drawShapeDetail[markerIndex].lng = latlng.lng; 832 drawShapeDetail[markerIndex].place_id = ''; 833 markerPositionsInput.value = JSON.stringify(drawShapeDetail); 834 geocoder.geocode({ 'location': latlng }, function (results, status) { 835 if (status === 'OK' && results && results.length) { 836 reInfowindow.setContent('<div id="map-popup"><textarea rows="2" cols="30" id="map-info_' + markerIndex + '" placeholder="Add your label here..."></textarea></div>'); 837 reInfowindow.setPosition(markerPos.latLng); 838 reInfowindow.open(map); 839 // Update title, lan, and lat. 840 drawShapeDetail[markerIndex].lat = results[0].geometry.location.lat(); 841 drawShapeDetail[markerIndex].lng = results[0].geometry.location.lng(); 842 drawShapeDetail[markerIndex].place_id = results[0].place_id || ''; 843 markerPositionsInput.value = JSON.stringify(drawShapeDetail); 844 // Function calling for the input title on popup. 845 infoWindowTitle(markerIndex); 846 } else if (status === 'ZERO_RESULTS') { 847 window.alert('No results found where you have dragend'); 848 } 849 }); 850 } 851 }); 799 852 } 800 853 801 854 // Submit map WordPress Ajax. 802 jQuery( document ).on( 'click', '.amm-maps-submit', function( e) {855 jQuery(document).on('click', '.amm-maps-submit', function (e) { 803 856 e.preventDefault(); 804 var formData = {805 action: 'addmultiplemarker_save_maps_data',806 form : jQuery( 'form.amm-get-location' ).serialize()807 }808 jQuery.post( amm_plugin_obj.ajax_url, formData,809 function ( response ) {810 var ajax_result = jQuery.parseJSON( response );811 jQuery( 'span.amm-maps-message' ).html( ajax_result.message);812 setTimeout( function() {813 jQuery( 'span.amm-maps-message' ).html( '');814 }, 3000);815 });857 var formData = jQuery('form.amm-get-location').serializeArray(); 858 formData.push({ 859 name: 'action', 860 value: 'addmultiplemarker_save_maps_data' 861 }) 862 jQuery.post(amm_plugin_obj.ajax_url, formData, 863 function (response) { 864 jQuery('span.amm-maps-message').html(response.data.message); 865 setTimeout(function () { 866 jQuery('span.amm-maps-message').html(''); 867 }, 3000); 868 }); 816 869 }); 817 870 818 871 // Reset map WordPress Ajax. 819 jQuery( document ).on( 'click', '#map-resets', function( e) {872 jQuery(document).on('click', '#map-resets', function (e) { 820 873 var confirmReset = confirm('Are you sure you want to reset the map?'); 821 if ( confirmReset ){874 if (confirmReset) { 822 875 var formData = { 876 nonce: jQuery('#amm_reset_map_nonce').val().trim(), 823 877 action: 'addmultiplemarker_reset_map' 824 878 } 825 jQuery.post( amm_plugin_obj.ajax_url, formData,826 function ( response) {827 if (response){828 window.location = window.location.href;829 }830 });879 jQuery.post(amm_plugin_obj.ajax_url, formData, 880 function (response) { 881 if (response) { 882 window.location = window.location.href; 883 } 884 }); 831 885 } 832 886 }); 833 887 834 jQuery( window ).on( 'load resize', function() {888 jQuery(window).on('load resize', function () { 835 889 mapStructure(); 836 890 }); 891 892 document.getElementById("dropMarkerBtn").addEventListener("click", function (e) { 893 e.preventDefault; 894 if (navigator.geolocation) { 895 navigator.geolocation.getCurrentPosition(function (position) { 896 if (!dropMarkerBtnState) { 897 return; 898 } 899 const index = allDrawShape.length; 900 const submitMap = document.getElementById('amm-maps-submit'); 901 if (submitMap.disabled == true) { 902 submitMap.disabled = false; 903 } 904 document.getElementById('drop_marker_wrap').style.display = 'none'; 905 document.getElementById('amm-maps-submit').disabled = false; 906 dropMarkerBtnState = false; 907 const pos = { 908 lat: position.coords.latitude, 909 lng: position.coords.longitude 910 }; 911 const uuid = Date.now(); 912 913 const marker = new google.maps.Marker({ 914 position: pos, 915 map: map, 916 type: 'marker', 917 draggable: true, 918 uuid: uuid 919 }); 920 currentLocation = position.coords; 921 drawShapeDetail.push({ uuid: uuid, lat: pos.lat, lng: pos.lng, img: [drawingManager.markerOptions.icon], title: '', place_id: '' }); 922 markerPositionsInput.value = JSON.stringify(drawShapeDetail); 923 // When push marker on map infowindow opens with custom label and you can edit it.. 924 geocoder.geocode({ 'location': pos }, function (results, status) { 925 if (status === 'OK' && results && results.length) { 926 var primaryResult = results[0]; 927 infowindow.setContent('<div id="map-popup"><textarea rows="2" cols="30" id="map-info_' + index + '" placeholder="Add your label here..."></textarea></div>'); 928 infowindow.open(map, marker); 929 drawShapeDetail[index].place_id = primaryResult.place_id || ''; 930 markerPositionsInput.value = JSON.stringify(drawShapeDetail); 931 } else if (status === 'ZERO_RESULTS') { 932 window.alert('No results found where you have clicked'); 933 } 934 }); 935 936 markerArray.push('marker'); 937 // Add value to input fields. 938 markerTypeInput.value = JSON.stringify(mapType); 939 940 allDrawShape.push(marker); 941 942 // Remove selected option from drawing tools. 943 drawingManager.setDrawingMode(null); 944 945 // Popup info window. 946 marker.addListener('dblclick', markerInfoWindow); 947 marker.addListener('click', () => { setDrawingShape(marker) }); 948 949 // Update lng and lat when drag the marker from one place to other place. 950 markerDragHandler(marker) 951 952 setDrawingShape(marker); 953 // Calling function for updating map title. 954 infoWindowTitle(index); 955 956 }, function () { 957 alert("Location access denied or unavailable."); 958 }); 959 960 } else { 961 alert("Geolocation not supported by this browser."); 962 } 963 }); -
add-multiple-marker/trunk/admin/map-integration.php
r2608577 r3433258 1 1 <?php 2 if ( isset( $_REQUEST['amm_submit'] ) && wp_verify_nonce( $_POST['_wpnonce'] ) ) { 3 $api_key = ( ( isset( $_POST['amm_api_key'] ) && $_POST['amm_api_key'] != "" ) ? sanitize_text_field( $_POST['amm_api_key'] ) : '' ); 4 $map_style = isset( $_POST['amm_map_theme'] ) ? sanitize_text_field( $_POST['amm_map_theme'] ) : ''; 5 $map_type = isset( $_POST['amm_map_style'] ) ? sanitize_text_field( $_POST['amm_map_style'] ) : ''; 6 $map_height = isset( $_POST['amm_front_map_height'] ) ? sanitize_text_field( $_POST['amm_front_map_height'] ) : ''; 7 $map_width = isset( $_POST['amm_front_map_width'] ) ? sanitize_text_field( $_POST['amm_front_map_width'] ) : ''; 8 // $map_zoom = isset( $_POST['amm_zoom_level'] ) ? sanitize_text_field( $_POST['amm_zoom_level'] ) : ''; 9 $map_full_screen = isset( $_POST['amm_fullscreencontrol'] ) ? sanitize_text_field( $_POST['amm_fullscreencontrol'] ) : ''; 10 $map_type_control = isset( $_POST['amm_maptypecontrol'] ) ? sanitize_text_field( $_POST['amm_maptypecontrol'] ) : ''; 11 $map_street_view = isset( $_POST['amm_streetviewcontrol'] ) ? sanitize_text_field( $_POST['amm_streetviewcontrol'] ) : ''; 12 // Map setting array. 2 /** 3 * Template file for map integration menu. 4 * 5 * @package addmultiplemarker 6 */ 7 8 if ( ! defined( 'ABSPATH' ) ) { 9 exit; 10 } 11 12 $nonce = isset( $_POST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ) : ''; 13 14 if ( isset( $_POST['amm_submit'] ) && wp_verify_nonce( $nonce, 'amm_map_integration' ) ) { 15 $api_key = ( ( isset( $_POST['amm_api_key'] ) && '' !== $_POST['amm_api_key'] ) ? sanitize_text_field( wp_unslash( $_POST['amm_api_key'] ) ) : '' ); 16 $map_style = isset( $_POST['amm_map_theme'] ) ? sanitize_text_field( wp_unslash( $_POST['amm_map_theme'] ) ) : ''; 17 $map_type = isset( $_POST['amm_map_style'] ) ? sanitize_text_field( wp_unslash( $_POST['amm_map_style'] ) ) : ''; 18 $map_height = isset( $_POST['amm_front_map_height'] ) ? sanitize_text_field( wp_unslash( $_POST['amm_front_map_height'] ) ) : ''; 19 $map_width = isset( $_POST['amm_front_map_width'] ) ? sanitize_text_field( wp_unslash( $_POST['amm_front_map_width'] ) ) : ''; 20 21 $map_full_screen = isset( $_POST['amm_fullscreencontrol'] ) ? '1' : ''; 22 $map_type_control = isset( $_POST['amm_maptypecontrol'] ) ? '1' : ''; 23 $map_street_view = isset( $_POST['amm_streetviewcontrol'] ) ? '1' : ''; 24 $map_height = ( 0 <= $map_height ) ? $map_height : ''; 25 26 $is_key_valid = addmultiplemarker_validate_map_key( $api_key ); 27 $api_key = $is_key_valid ? $api_key : ''; 28 29 // Map setting array. 13 30 $map_settings = array( 14 31 'api' => $api_key, … … 17 34 'map_height' => $map_height, 18 35 'map_width' => $map_width, 19 //'map_zoom' => $map_zoom, 20 'map_full_screen' => $map_full_screen, 21 'map_type_control' => $map_type_control, 22 'map_street_view' => $map_street_view, 36 'map_full_screen' => $map_full_screen, 37 'map_type_control' => $map_type_control, 38 'map_street_view' => $map_street_view, 23 39 ); 24 // Store value into option table. 40 41 // Store value into option table. 25 42 $setting_saved = update_option( 'amm_map_setting', $map_settings ); 26 if ( $api_key == "" ){27 $error_msg = __( 'Please Enter Google API key', 'add multiplemarker' );43 if ( '' === $api_key ) { 44 $error_msg = __( 'Please Enter Google API key', 'add-multiple-marker' ); 28 45 } 29 if ( $setting_saved && $api_key != "") {30 $success_msg = __( 'Settings saved successfully', 'add multiplemarker' );46 if ( $setting_saved && '' !== $api_key ) { 47 $success_msg = __( 'Settings saved successfully', 'add-multiple-marker' ); 31 48 } 32 } ?> 49 } 50 51 $retrieve_map_settings = get_option( 'amm_map_setting' ); 52 $default_map_settings = array( 53 'api' => '', 54 'map_theme' => 'standard', 55 'map_style' => 'roadmap', 56 'map_width' => '', 57 'map_height' => '', 58 'map_zoom' => '', 59 'map_full_screen' => '', 60 'map_type_control' => '', 61 'map_street_view' => '', 62 ); 63 64 $get_settings = wp_parse_args( 65 $retrieve_map_settings, 66 $default_map_settings 67 ); 68 ?> 33 69 34 70 <div class="amm-admin-main-wrap"> 35 71 <div class="amm-map-integration-wrap"> 36 72 <form method="POST" name="amm_map_integration" id="amm_map_integration"> 37 <?php wp_nonce_field(); 38 $retrieve_map_settings = get_option( 'amm_map_setting' ); 39 if ( !empty( $retrieve_map_settings ) ) { 40 $api = $retrieve_map_settings['api']; 41 $theme = isset( $retrieve_map_settings['map_theme'] ) ? $retrieve_map_settings['map_theme'] : 'standard'; 42 $map_type = isset( $retrieve_map_settings['map_style'] ) ? $retrieve_map_settings['map_style'] : 'roadmap'; 43 $map_width = isset( $retrieve_map_settings['map_width'] ) ? $retrieve_map_settings['map_width'] : ''; 44 $map_height = isset( $retrieve_map_settings['map_height'] ) ? $retrieve_map_settings['map_height'] : ''; 45 $map_zoom = isset( $retrieve_map_settings['map_zoom'] ) ? $retrieve_map_settings['map_zoom'] : ''; 46 $map_full_screen = isset( $retrieve_map_settings['map_full_screen'] ) ? $retrieve_map_settings['map_full_screen'] : ''; 47 $map_type_control = isset( $retrieve_map_settings['map_type_control'] ) ? $retrieve_map_settings['map_type_control'] : ''; 48 $map_street_view = isset( $retrieve_map_settings['map_street_view'] ) ? $retrieve_map_settings['map_street_view'] : ''; 49 } ?> 50 <div class="left-align-section"> 51 <div class="amm-api-section amm-panel"> 52 <fieldset> 53 <legend><?php _e( 'Map API Key', 'addmultiplemarker' ); ?></legend> 54 <input class="amm-input" type="text" name="amm_api_key" value="<?php echo ( isset( $api ) ? $api : '' ); ?>" placeholder="<?php _e( 'Please enter your API key here', 'addmultiplemarker' ); ?>"> 55 <span class="error error-span"><?php echo isset( $error_msg ) ? $error_msg : ''; ?></span> 56 </fieldset> 57 </div> 73 <?php wp_nonce_field( 'amm_map_integration' ); ?> 74 <div class="left-align-section"> 75 <div class="amm-api-section amm-panel"> 76 <fieldset> 77 <legend><?php esc_html_e( 'Map API Key', 'add-multiple-marker' ); ?></legend> 78 <input class="amm-input" type="text" name="amm_api_key" value="<?php echo esc_attr( $get_settings['api'] ); ?>" 79 placeholder="<?php echo esc_attr__( 'Please enter your API key here', 'add-multiple-marker' ); ?>"> 80 <span class="error error-span"><?php echo isset( $error_msg ) ? esc_html( $error_msg ) : esc_html( '' ); ?></span> 81 </fieldset> 82 </div> 58 83 59 <div class="amm-map-theme-style amm-panel"> 60 <fieldset> 61 <legend><?php _e('Map Type','addmultiplemarker'); ?></legend> 62 <label class="label"> 63 <input type="radio" name="amm_map_style" value="roadmap" <?php echo ( ( isset ( $map_type ) && $map_type == 'roadmap' ) ? 'checked' : '' ); ?> <?php echo (!isset( $map_type ) ? 'checked': ''); ?> > 64 <?php esc_attr_e( 'Roadmap', 'addmultiplemarker' ); ?> 65 </label> 66 <label class="label"> 67 <input type="radio" name="amm_map_style" value="satellite" <?php echo ( ( isset ( $map_type ) && $map_type == 'satellite' ) ? 'checked' : '' ); ?>> 68 <?php esc_attr_e( 'Satellite', 'addmultiplemarker' ); ?> 69 </label> 70 <label class="label"> 71 <input type="radio" name="amm_map_style" value="hybrid" <?php echo ( ( isset ( $map_type ) && $map_type == 'hybrid' ) ? 'checked' : '' ); ?>><?php esc_attr_e( 'Hybrid', 'addmultiplemarker' ); ?> 72 </label> 73 <label class="label"> 74 <input type="radio" name="amm_map_style" value="terrain" <?php echo ( ( isset ( $map_type ) && $map_type == 'terrain' ) ? 'checked' : '' ); ?>><?php esc_attr_e( 'Terrain', 'addmultiplemarker' ); ?> 75 </label> 76 </fieldset> 77 </div> 78 <div class="amm-dimensions amm-panel"> 79 <fieldset> 80 <legend><?php _e( 'Width','addmultiplemarker' ); ?></legend> 81 <input class="amm-input" type="text" value="<?php echo ( isset( $map_width ) ? $map_width : '' ); ?>" name="amm_front_map_width" placeholder="eg. 100%"> 82 </fieldset> 83 </div> 84 <div class="amm-dimensions amm-panel"> 85 <fieldset> 86 <legend><?php _e( 'Height','addmultiplemarker' ); ?></legend> 87 <input class="amm-input" type="text" value="<?php echo ( isset( $map_height ) ? $map_height : '' ); ?>" name="amm_front_map_height" placeholder="eg. 100px"> 88 </fieldset> 89 </div> 90 </div> 91 <div class="right-align-section"> 92 <!-- <div class="map-config-section amm-panel"> 93 <fieldset> 94 <legend><?php esc_attr_e( 'Zoom Level', 'addmultiplemarker' ); ?></legend> 95 <input type="number" name="amm_zoom_level" id="amm_zoom_level" class="amm-input" value="<?php echo ( isset( $map_zoom ) ? $map_zoom : '' ); ?>"> 96 </fieldset> 97 </div> --> 98 <input type="hidden" name="amm_zoom_level" id="amm_zoom_level" class="amm-input" value="<?php echo ( isset( $map_zoom ) ? $map_zoom : '' ); ?>"> 99 <div class="map-config-section amm-panel"> 100 <fieldset> 101 <legend><?php esc_attr_e( 'Map Control', 'addmultiplemarker' ); ?></legend> 102 <input type="checkbox" name="amm_fullscreencontrol" id="amm_fullscreencontrol" <?php if ( !empty( $map_full_screen ) ): echo 'checked="checked"'; endif; ?>><?php esc_attr_e( 'Full Screen Control', 'addmultiplemarker' ); ?> 103 </fieldset> 104 <fieldset> 105 <input type="checkbox" name="amm_maptypecontrol" id="amm_maptypecontrol" <?php if ( !empty( $map_type_control ) ): echo 'checked="checked"'; endif; ?>><?php esc_attr_e( 'Map Type Control', 'addmultiplemarker' ); ?> 106 </fieldset> 107 <fieldset> 108 <input type="checkbox" name="amm_streetviewcontrol" id="amm_streetviewcontrol" <?php if ( !empty( $map_street_view ) ): echo 'checked="checked"'; endif; ?>><?php esc_attr_e( 'Street View Control', 'addmultiplemarker' ); ?> 109 </fieldset> 110 </div> 84 <div class="amm-map-theme-style amm-panel"> 85 <?php 86 $map_types = array( 87 'roadmap' => __( 'Roadmap', 'add-multiple-marker' ), 88 'satellite' => __( 'Satellite', 'add-multiple-marker' ), 89 'hybrid' => __( 'Hybrid', 'add-multiple-marker' ), 90 'terrain' => __( 'Terrain', 'add-multiple-marker' ), 91 ); 92 ?> 93 <fieldset> 94 <legend><?php esc_html_e( 'Map Type', 'add-multiple-marker' ); ?></legend> 95 <?php foreach ( $map_types as $key => $map_type ) { ?> 96 <label class="label"> 97 <input type="radio" name="amm_map_style" value="<?php echo esc_attr( $key ); ?>" <?php checked( $get_settings['map_style'], $key ); ?>> 98 <?php echo esc_attr( $map_type ); ?> 99 </label> 100 <?php } ?> 101 </fieldset> 102 </div> 103 <div class="amm-dimensions amm-panel"> 104 <fieldset> 105 <legend><?php esc_html_e( 'Width', 'add-multiple-marker' ); ?></legend> 106 <input class="amm-input" type="text" value="<?php echo esc_attr( $get_settings['map_width'] ); ?>" name="amm_front_map_width" placeholder="eg. 100%"> 107 </fieldset> 108 </div> 109 <div class="amm-dimensions amm-panel"> 110 <fieldset> 111 <legend><?php esc_html_e( 'Height', 'add-multiple-marker' ); ?> ( px )</legend> 112 <input class="amm-input" type="number" value="<?php echo esc_attr( $get_settings['map_height'] ); ?>" min="0" name="amm_front_map_height" placeholder="eg. 100px"> 113 </fieldset> 114 </div> 115 </div> 116 <div class="right-align-section"> 117 <input type="hidden" name="amm_zoom_level" id="amm_zoom_level" class="amm-input" value="<?php echo esc_attr( $get_settings['map_zoom'] ); ?>"> 118 <div class="map-config-section amm-panel"> 119 <fieldset> 120 <legend><?php esc_html_e( 'Map Control', 'add-multiple-marker' ); ?></legend> 121 <label> 122 <input type="checkbox" name="amm_fullscreencontrol" id="amm_fullscreencontrol" value="1" <?php checked( $get_settings['map_full_screen'], '1' ); ?>> 123 <?php esc_html_e( 'Full Screen Control', 'add-multiple-marker' ); ?> 124 </label> 125 </fieldset> 126 <fieldset> 127 <label> 128 <input type="checkbox" name="amm_maptypecontrol" id="amm_maptypecontrol" value="1" <?php checked( $get_settings['map_type_control'], '1' ); ?>> 129 <?php esc_html_e( 'Map Type Control', 'add-multiple-marker' ); ?> 130 </label> 131 </fieldset> 132 <fieldset> 133 <label> 134 <input type="checkbox" name="amm_streetviewcontrol" id="amm_streetviewcontrol" value="1" <?php checked( $get_settings['map_street_view'], '1' ); ?>> 135 <?php esc_html_e( 'Street View Control', 'add-multiple-marker' ); ?> 136 </label> 137 </fieldset> 138 </div> 111 139 112 <div class="amm-map-theme-section amm-panel"> 113 <fieldset> 114 <legend><?php _e('Map style','addmultiplemarker'); ?></legend> 115 <label class="label"> 116 <input type="radio" name="amm_map_theme" value="standard" <?php echo ( ( isset ( $theme ) && $theme == 'standard' ) ? 'checked' : '' ); ?> 117 <?php echo ( ! isset( $theme ) ? 'checked': '' ); ?> > 118 <span class="text"><?php esc_attr_e( 'Standard', 'addmultiplemarker' ); ?></span> 119 <img src="<?php echo ADDMULTIPLEMARKER_PLUGIN_URL ?>admin/images/Standard.jpg" alt="map-style"> 120 </label> 121 <label class="label"> 122 <input type="radio" name="amm_map_theme" value="silver" <?php echo ( ( isset ( $theme ) && $theme == 'silver' ) ? 'checked' : '' ); ?>> 123 <span class="text"><?php esc_attr_e( 'Silver', 'addmultiplemarker' ); ?></span> 124 <img src="<?php echo ADDMULTIPLEMARKER_PLUGIN_URL ?>admin/images/Silver.jpg" alt="map-style"> 125 </label> 126 <label class="label"> 127 <input type="radio" name="amm_map_theme" value="retro" <?php echo ( ( isset ( $theme ) && $theme == 'retro' ) ? 'checked' : '' ); ?>> 128 <span class="text"><?php esc_attr_e( 'Retro', 'addmultiplemarker' ); ?></span> 129 <img src="<?php echo ADDMULTIPLEMARKER_PLUGIN_URL ?>admin/images/Retro.jpg" alt="map-style"> 130 </label> 131 <label class="label"> 132 <input type="radio" name="amm_map_theme" value="dark" <?php echo ( ( isset ( $theme ) && $theme == 'dark' ) ? 'checked' : '' ); ?>> 133 <span class="text"><?php esc_attr_e( 'Dark', 'addmultiplemarker' ); ?></span> 134 <img src="<?php echo ADDMULTIPLEMARKER_PLUGIN_URL ?>admin/images/Dark.jpg" alt="map-style"> 135 </label> 136 <label class="label"> 137 <input type="radio" name="amm_map_theme" value="night" <?php echo ( ( isset ( $theme ) && $theme == 'night' ) ? 'checked' : '' ); ?>> 138 <span class="text"><?php esc_attr_e( 'Night', 'addmultiplemarker' ); ?></span> 139 <img src="<?php echo ADDMULTIPLEMARKER_PLUGIN_URL ?>admin/images/Night.jpg" alt="map-style"> 140 </label> 141 <label class="label"> 142 <input type="radio" name="amm_map_theme" value="aubergine" <?php echo ( ( isset ( $theme ) && $theme == 'aubergine' ) ? 'checked' : '' ); ?>> 143 <span class="text"><?php esc_attr_e( 'Aubergine', 'addmultiplemarker' ); ?></span> 144 <img src="<?php echo ADDMULTIPLEMARKER_PLUGIN_URL ?>admin/images/Aubergine.jpg" alt="map-style"> 145 </label> 146 </fieldset> 147 </div> 148 <div class="amm-call-to-btn"> 149 <input type="submit" name="amm_submit" value="Save" class="submit"> 150 </div> 151 </div> 152 140 <div class="amm-map-theme-section amm-panel"> 141 <fieldset> 142 <legend><?php esc_html_e( 'Map style', 'add-multiple-marker' ); ?></legend> 143 <?php 144 $map_themes = array( 145 'standard' => array( __( 'Standard', 'add-multiple-marker' ), 'Standard.jpg' ), 146 'silver' => array( __( 'Silver', 'add-multiple-marker' ), 'Silver.jpg' ), 147 'retro' => array( __( 'Retro', 'add-multiple-marker' ), 'Retro.jpg' ), 148 'dark' => array( __( 'Dark', 'add-multiple-marker' ), 'Dark.jpg' ), 149 'night' => array( __( 'Night', 'add-multiple-marker' ), 'Night.jpg' ), 150 'aubergine' => array( __( 'Aubergine', 'add-multiple-marker' ), 'Aubergine.jpg' ), 151 ); 153 152 154 <?php echo isset( $success_msg ) ? '<div class="success-msg">' . $success_msg . '</div>' : ''; ?> 153 foreach ( $map_themes as $key => $map_theme ) { 154 $image_url = ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/images/' . $map_theme[1]; 155 ?> 156 <label class="label"> 157 <input type="radio" name="amm_map_theme" value="<?php echo esc_attr( $key ); ?>" 158 <?php checked( $get_settings['map_theme'], $key ); ?>> 159 <span class="text"><?php echo esc_html( $map_theme[0] ); ?></span> 160 <img src="<?php echo esc_url( $image_url ); ?>" alt="map-style"> 161 </label> 162 <?php } ?> 163 </fieldset> 164 </div> 165 <div class="amm-call-to-btn"> 166 <input type="submit" name="amm_submit" value="Save" class="submit"> 167 </div> 168 <?php if ( isset( $success_msg ) ) { ?> 169 <span class="success-msg"><?php echo esc_html( $success_msg ); ?></dspaniv> 170 <?php } ?> 171 </div> 155 172 </form> 173 <?php 174 if ( ! $get_settings['api'] ) { 175 wp_nonce_field( 'amm_save_map_api', 'amm_api_key_nonce' ); 176 } 177 ?> 156 178 </div> 157 179 </div> -
add-multiple-marker/trunk/functions.php
r2608577 r3433258 1 1 <?php 2 2 /** 3 * Additional functions. 4 * 3 5 * @package addmultiplemarker 4 6 */ 5 7 8 if ( ! defined( 'ABSPATH' ) ) { 9 exit; 10 } 11 6 12 if ( ! class_exists( 'Addmultiplemarker' ) ) { 7 /**8 * Create a class for adding all the functionality.9 */13 /** 14 * Create a class for adding all the functionality. 15 */ 10 16 class Addmultiplemarker { 11 /** 12 * Calling class __construct. 13 */ 14 function __construct() { 15 // Enqueue scripts. 16 add_action( 'admin_enqueue_scripts', array( $this, 'addmultiplemarker_admin_scripts' ) ); 17 add_action( 'wp_enqueue_scripts', array( $this, 'addmultiplemarker_scripts' ) ); 18 19 // Include admin menu. 20 add_action( 'admin_menu', array( $this, 'addmultiplemarker_admin_menu' ) ); 21 22 // // Included google api url on backend and frontend. 23 // $map_api_details = $this->get_data_from_db( 'map_integration' ); 24 // $map_api = ( $map_api_details && $map_api_details['api'] != '' ) ? $map_api_details['api'] : ''; 25 // if ( $map_api != '' ) { 26 // wp_enqueue_script( 'amm-map-script', 'https://maps.googleapis.com/maps/api/js?key=' . $map_api . '&libraries=drawing,places', array( 'jquery' ), false, true ); 27 // } 28 29 // Adding shortcode for displaying related posts on frontside. 30 add_shortcode( 'addmultiplemarker', array( $this, 'display_multiple_marker_map' ) ); 31 // Load text domain. 32 add_action( 'plugins_loaded', array( $this, 'addmultiplemarker_load_textdomain' ) ); 33 // Display notices when key is not API valid. 34 add_action( 'admin_notices', array( $this, 'addmultiplemarker_admin_notice' )); 17 /** 18 * Calling class __construct. 19 */ 20 public function __construct() { 21 add_action( 'admin_enqueue_scripts', array( $this, 'addmultiplemarker_admin_scripts' ) ); 22 add_action( 'wp_enqueue_scripts', array( $this, 'addmultiplemarker_scripts' ) ); 23 add_action( 'admin_menu', array( $this, 'addmultiplemarker_admin_menu' ) ); 24 add_shortcode( 'addmultiplemarker', array( $this, 'display_multiple_marker_map' ) ); 25 add_action( 'admin_notices', array( $this, 'addmultiplemarker_admin_notice' ) ); 35 26 } 36 27 … … 38 29 * Include admin style and scripts. 39 30 */ 40 function addmultiplemarker_admin_scripts() { 41 wp_enqueue_style( 'amm-admin-css', ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/css/amm-style.css' ); 42 wp_enqueue_style( 'amm-font-css', ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/fonts/sanasansalt.css' ); 31 public function addmultiplemarker_admin_scripts() { 32 $current_page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended 33 34 if ( 'addmultiplemarker' !== $current_page && 'amm-map-integration' !== $current_page ) { 35 return; 36 } 37 wp_enqueue_style( 'amm-admin-css', ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/css/amm-style.css', '', ADDMULTIPLEMARKER_VERSION ); 38 wp_enqueue_style( 'amm-font-css', ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/fonts/sanasansalt.css', '', ADDMULTIPLEMARKER_VERSION ); 43 39 wp_enqueue_style( 'wp-color-picker' ); 44 wp_enqueue_script( 'amm-jquery-blockui', ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/js/jquery.blockUI.js', array( 'jquery' ), false, true ); 40 wp_enqueue_script( 41 'amm-jquery-blockui', 42 ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/js/jquery.blockUI.js', 43 array( 'jquery' ), 44 ADDMULTIPLEMARKER_VERSION, 45 true 46 ); 45 47 // Include scripts. 46 48 wp_enqueue_script( 'wp-color-picker' ); 47 49 // Included google api url. 48 50 $map_api_details = $this->get_data_from_db( 'map_integration' ); 49 $map_api = ( $map_api_details && $map_api_details['api'] != '' ) ? $map_api_details['api'] : ''; 50 if ( $map_api != '' && isset( $_GET['page'] ) && $_GET['page'] == 'addmultiplemarker' ) { 51 wp_enqueue_script( 'amm-map-script', 'https://maps.googleapis.com/maps/api/js?key=' . $map_api . '&libraries=drawing,places', array( 'jquery' ), false, true ); 52 wp_enqueue_script( 'amm-admin-script', ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/js/amm-scripts.js', array( ), false, true ); 53 } 54 wp_enqueue_script( 'amm-admin-custom-script', ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/js/amm-custom-settings.js', array( ), false, true ); 55 wp_localize_script( 'amm-admin-script', 'amm_plugin_obj', 51 $map_api = ( $map_api_details && '' !== $map_api_details['api'] ) ? $map_api_details['api'] : ''; 52 53 if ( '' !== $map_api && $current_page && 'addmultiplemarker' === $current_page ) { 54 wp_enqueue_script( 55 'amm-map-script', 56 'https://maps.googleapis.com/maps/api/js?key=' . $map_api . '&libraries=drawing,places', 57 array(), 58 ADDMULTIPLEMARKER_VERSION, 59 true 60 ); 61 wp_enqueue_script( 62 'amm-admin-script', 63 ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/js/amm-scripts.js', 64 array( 'jquery' ), 65 ADDMULTIPLEMARKER_VERSION, 66 true 67 ); 68 } 69 70 wp_enqueue_script( 71 'amm-admin-custom-script', 72 ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/js/amm-custom-settings.js', 73 array(), 74 ADDMULTIPLEMARKER_VERSION, 75 true 76 ); 77 wp_localize_script( 78 'amm-admin-script', 79 'amm_plugin_obj', 56 80 array( 57 'plugin_path' => ADDMULTIPLEMARKER_PLUGIN_URL,81 'plugin_path' => ADDMULTIPLEMARKER_PLUGIN_URL, 58 82 'amm_save_option' => $this->get_data_from_db( 'marker_settings' ), 59 'ajax_url' => admin_url( 'admin-ajax.php' ),60 'map_settings' => $this->get_data_from_db( 'map_integration' ),83 'ajax_url' => admin_url( 'admin-ajax.php' ), 84 'map_settings' => $this->get_data_from_db( 'map_integration' ), 61 85 ) 62 86 ); 63 wp_localize_script( 'amm-admin-custom-script', 'amm_plugin_custom_obj', 87 wp_localize_script( 88 'amm-admin-custom-script', 89 'amm_plugin_custom_obj', 64 90 array( 65 91 'ajax_url' => admin_url( 'admin-ajax.php' ), … … 71 97 * Include frontend style and scripts. 72 98 */ 73 function addmultiplemarker_scripts() { 74 wp_enqueue_style( 'amm-frontend-styles', ADDMULTIPLEMARKER_PLUGIN_URL . 'public/css/amm-frontend-style.css' ); 75 76 // Include scripts. 77 // wp_enqueue_script('amm-frontend-scripts', ADDMULTIPLEMARKER_PLUGIN_URL . 'public/js/frontendscript.js', array( 'jquery' ), '', true); 78 // wp_localize_script( 'amm-frontend-scripts', 'amm_frontend_obj', 79 // array( 80 // 'amm_save_marker_option' => $this->get_data_from_db( 'marker_settings' ), 81 // 'map_settings' => $this->get_data_from_db( 'map_integration' ), 82 // ) 83 // ); 99 public function addmultiplemarker_scripts() { 100 wp_enqueue_style( 101 'amm-frontend-styles', 102 ADDMULTIPLEMARKER_PLUGIN_URL . 'public/css/amm-frontend-style.css', 103 '', 104 ADDMULTIPLEMARKER_VERSION 105 ); 84 106 } 85 107 86 108 /** 87 109 * Get data from database. 88 */ 89 function get_data_from_db( $option_name ) { 90 if ( $option_name == 'map_integration' ) { 110 * 111 * @param string $option_name Option name. 112 */ 113 public function get_data_from_db( $option_name ) { 114 if ( 'map_integration' === $option_name ) { 91 115 $map_details = get_option( 'amm_map_setting' ); 92 } elseif ( $option_name == 'marker_settings') {116 } elseif ( 'marker_settings' === $option_name ) { 93 117 $map_details = get_option( 'amm_maps_marker' ); 94 118 } … … 99 123 * Register admin menu. 100 124 */ 101 function addmultiplemarker_admin_menu() {125 public function addmultiplemarker_admin_menu() { 102 126 add_menu_page( 103 __( 'Add Multiple Marker', 'addmultiplemarker' ),104 'Add Multiple Marker',105 'manage_options',106 'addmultiplemarker',107 array( $this, 'addmultiplemarker_global_settings_page' ),108 ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/images/dash-icon.png'109 );110 add_submenu_page(111 'addmultiplemarker',112 __( 'AMM Map integration', 'addmultiplemarker' ),113 __( 'Map integration', 'addmultiplemarker' ),114 'manage_options',115 'amm-map-integration',116 array( $this, 'addmultiplemarker_map_integration_callback' )117 );127 __( 'Add Multiple Marker', 'add-multiple-marker' ), 128 'Add Multiple Marker', 129 'manage_options', 130 'addmultiplemarker', 131 array( $this, 'addmultiplemarker_global_settings_page' ), 132 ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/images/dash-icon.png' 133 ); 134 add_submenu_page( 135 'addmultiplemarker', 136 __( 'AMM Map integration', 'add-multiple-marker' ), 137 __( 'Map integration', 'add-multiple-marker' ), 138 'manage_options', 139 'amm-map-integration', 140 array( $this, 'addmultiplemarker_map_integration_callback' ) 141 ); 118 142 } 119 143 … … 121 145 * Displaying admin notice. 122 146 */ 123 function addmultiplemarker_admin_notice() { 124 if ( isset( $_REQUEST['page'] ) && ( $_REQUEST['page'] == 'addmultiplemarker' || $_REQUEST['page'] == 'amm-map-integration') ) { 125 $map_details = $this->get_data_from_db( 'map_integration' ); 126 if ( !$map_details || $map_details['api'] == "" ) { 127 '<div id="message" class="error notice"><p>' . __( 'Please enter valid Google Map API for displaying map.', 'addmultiplemarker') . '</p></div>'; 128 } 129 } 130 } 131 132 /** 133 * Load Text domain. 134 */ 135 function addmultiplemarker_load_textdomain() { 136 load_plugin_textdomain( 'addmultiplemarker', false, basename( dirname( __FILE__ ) ) . '/languages' ); 137 } 138 139 /* 140 * Display map frontside via shortcode. 141 */ 142 function display_multiple_marker_map() { 147 public function addmultiplemarker_admin_notice() { 148 $current_page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended 149 if ( $current_page && ( 'addmultiplemarker' === $current_page || 'amm-map-integration' === $current_page ) ) { 150 $map_details = $this->get_data_from_db( 'map_integration' ); 151 if ( ! $map_details || ( isset( $map_details['api'] ) && '' === $map_details['api'] ) ) { 152 echo '<div id="message" class="error notice"><p>' . esc_html__( 'Please enter valid Google Map API for displaying map.', 'add-multiple-marker' ) . '</p></div>'; 153 } 154 } 155 } 156 157 /** 158 * Display map frontside via shortcode. 159 */ 160 public function display_multiple_marker_map() { 143 161 $map_details = $this->get_data_from_db( 'map_integration' ); 144 if ( $map_details ['api'] != "") {145 if ( ! wp_script_is( 'amm-map-script' ) ){146 wp_enqueue_script( 'amm-map-script', 'https://maps.googleapis.com/maps/api/js?key=' . $map_details['api'] . '&libraries=drawing,places ', array( 'jquery' ), false, true );162 if ( $map_details && isset( $map_details['api'] ) && '' !== $map_details['api'] ) { 163 if ( ! wp_script_is( 'amm-map-script' ) ) { 164 wp_enqueue_script( 'amm-map-script', 'https://maps.googleapis.com/maps/api/js?key=' . $map_details['api'] . '&libraries=drawing,places,marker&callback=initialize&loading=async', array(), ADDMULTIPLEMARKER_VERSION, true ); 147 165 } 148 if ( !wp_script_is( 'amm-frontend-scripts' ) ){ 149 wp_enqueue_script('amm-frontend-scripts', ADDMULTIPLEMARKER_PLUGIN_URL . 'public/js/frontendscript.js', array( 'jquery' ), '', true); 150 wp_localize_script( 'amm-frontend-scripts', 'amm_frontend_obj', 151 array( 152 'amm_save_marker_option' => $this->get_data_from_db( 'marker_settings' ), 153 'map_settings' => $this->get_data_from_db( 'map_integration' ), 154 ) 155 ); 166 if ( ! wp_script_is( 'amm-frontend-scripts' ) ) { 167 wp_enqueue_script( 'amm-frontend-scripts', ADDMULTIPLEMARKER_PLUGIN_URL . 'public/js/frontendscript.js', array( 'jquery' ), ADDMULTIPLEMARKER_VERSION, true ); 168 wp_localize_script( 169 'amm-frontend-scripts', 170 'amm_frontend_obj', 171 array( 172 'amm_save_marker_option' => $this->get_data_from_db( 'marker_settings' ), 173 'map_settings' => $this->get_data_from_db( 'map_integration' ), 174 ) 175 ); 156 176 } 157 $map_height = isset( $map_details['map_height'] ) && $map_details['map_height'] != "" ? $map_details['map_height'] : '500px';158 $map_width = isset( $map_details['map_width'] ) && $map_details['map_width'] != "" ? $map_details['map_width'] : '100%';159 return '<div class="amm-map-integrate" id="frontmap" style="height:' . $map_height . ' ;width:' . $map_width . ';"></div>';177 $map_height = isset( $map_details['map_height'] ) && '' !== $map_details['map_height'] ? $map_details['map_height'] : '500'; 178 $map_width = isset( $map_details['map_width'] ) && '' !== $map_details['map_width'] ? $map_details['map_width'] : '100%'; 179 return '<div class="amm-map-integrate" id="frontmap" style="height:' . $map_height . 'px;width:' . $map_width . ';"></div>'; 160 180 } else { 161 return __( 'Please Enter Valid Google Map API Key', 'add multiplemarker' );181 return __( 'Please Enter Valid Google Map API Key', 'add-multiple-marker' ); 162 182 } 163 183 } … … 166 186 * Map API configuration. 167 187 */ 168 function addmultiplemarker_global_settings_page() {188 public function addmultiplemarker_global_settings_page() { 169 189 // Include file. 170 require_once ( ADDMULTIPLEMARKER_PLUGIN_DIR . 'admin/admin-options.php' );190 require_once ADDMULTIPLEMARKER_PLUGIN_DIR . 'admin/admin-options.php'; 171 191 } 172 192 … … 174 194 * Setting configuration. 175 195 */ 176 function addmultiplemarker_map_integration_callback() {196 public function addmultiplemarker_map_integration_callback() { 177 197 // Include file. 178 require_once ( ADDMULTIPLEMARKER_PLUGIN_DIR . 'admin/map-integration.php' );198 require_once ADDMULTIPLEMARKER_PLUGIN_DIR . 'admin/map-integration.php'; 179 199 } 180 200 } 181 182 201 } 183 184 // Admin ajax to submit all the markers detail into the database.185 add_action( 'wp_ajax_addmultiplemarker_save_maps_data', 'addmultiplemarker_save_maps_data' );186 add_action( 'wp_ajax_nopriv_addmultiplemarker_save_maps_data', 'addmultiplemarker_save_maps_data' );187 function addmultiplemarker_save_maps_data() {188 if ( isset( $_POST['form'] ) ) {189 $unserialize_formdata = array();190 parse_str( $_POST['form'], $unserialize_formdata );191 if ( wp_verify_nonce( $unserialize_formdata['_wpnonce'] ) ) {192 $removeKeys = array( '_wpnonce', '_wp_http_referer', 'amm_search_area' );193 foreach ( $removeKeys as $key ) {194 unset( $unserialize_formdata[$key] );195 }196 $save_db = update_option( 'amm_maps_marker', $unserialize_formdata );197 if ( $save_db ) {198 $msg = array( 'result' => '1', 'message' => __( 'Your changes saved successfully.','addmultiplemarker' ) );199 }else{200 $msg = array( 'result' => '0', 'message' => __( 'You have not done any changes.','addmultiplemarker' ) );201 }202 } else {203 $msg = array( 'result' => '0', 'message' => __( 'Security check', 'addmultiplemarker' ) );204 }205 } else {206 $msg = array( 'result' => '0', 'message' => __( 'Unauthorize Access', 'addmultiplemarker' ) );207 }208 echo json_encode( $msg );209 wp_die();210 }211 212 add_action( 'wp_ajax_addmultiplemarker_reset_map', 'addmultiplemarker_reset_map' );213 add_action( 'wp_ajax_nopriv_addmultiplemarker_reset_map', 'addmultiplemarker_reset_map' );214 function addmultiplemarker_reset_map() {215 $option_deleted = delete_option('amm_maps_marker');216 return $option_deleted;217 }218 219 220 add_action( 'wp_ajax_amm_save_map_api', 'amm_save_map_api' );221 add_action( 'wp_ajax_nopriv_amm_save_map_api', 'amm_save_map_api' );222 function amm_save_map_api(){223 if ( isset( $_POST['apiKeyValue'] ) && $_POST['apiKeyValue'] != '' ){224 $existing_map_setting = get_option('amm_map_setting');225 $map_settings = array(226 'api' => sanitize_text_field( $_POST['apiKeyValue'] ),227 );228 229 if ( $existing_map_setting ){230 unset( $existing_map_setting['api'] );231 $map_settings = array_merge( $map_settings, $existing_map_setting );232 }233 234 // Store value into option table.235 $setting_saved = update_option( 'amm_map_setting', $map_settings );236 if ($setting_saved){237 $msg = array( 'result' => '1', 'message' => __( 'Your changes saved successfully','addmultiplemarker' ) );238 }239 }else{240 $msg = array('result' => '0', 'message'=> __('Please Enter Valid Google Map Api Key','addmultiplemarker') );241 }242 echo wp_json_encode( $msg );243 wp_die();244 } -
add-multiple-marker/trunk/index.php
r1986887 r3433258 1 <?php 2 #Silence is golden.1 <?php // phpcs:ignoreFile 2 // Silence is golden. -
add-multiple-marker/trunk/public/js/frontendscript.js
r2608577 r3433258 1 // Global variable. 2 var geocoder; 3 var map; 1 const mapSettings = amm_frontend_obj.map_settings; 2 const mapType = mapSettings.map_style; 3 const mapStyleType = mapSettings.map_theme; 4 const mapStyles = { 5 standard: [], 6 silver: [{ "elementType": "geometry", "stylers": [{ "color": "#f5f5f5" }] }, { "elementType": "labels.icon", "stylers": [{ "visibility": "off" }] }, { "elementType": "labels.text.fill", "stylers": [{ "color": "#616161" }] }, { "elementType": "labels.text.stroke", "stylers": [{ "color": "#f5f5f5" }] }, { "featureType": "administrative.land_parcel", "elementType": "labels.text.fill", "stylers": [{ "color": "#bdbdbd" }] }, { "featureType": "poi", "elementType": "geometry", "stylers": [{ "color": "#eeeeee" }] }, { "featureType": "poi", "elementType": "labels.text.fill", "stylers": [{ "color": "#757575" }] }, { "featureType": "poi.park", "elementType": "geometry", "stylers": [{ "color": "#e5e5e5" }] }, { "featureType": "poi.park", "elementType": "labels.text.fill", "stylers": [{ "color": "#9e9e9e" }] }, { "featureType": "road", "elementType": "geometry", "stylers": [{ "color": "#ffffff" }] }, { "featureType": "road.arterial", "elementType": "labels.text.fill", "stylers": [{ "color": "#757575" }] }, { "featureType": "road.highway", "elementType": "geometry", "stylers": [{ "color": "#dadada" }] }, { "featureType": "road.highway", "elementType": "labels.text.fill", "stylers": [{ "color": "#616161" }] }, { "featureType": "road.local", "elementType": "labels.text.fill", "stylers": [{ "color": "#9e9e9e" }] }, { "featureType": "transit.line", "elementType": "geometry", "stylers": [{ "color": "#e5e5e5" }] }, { "featureType": "transit.station", "elementType": "geometry", "stylers": [{ "color": "#eeeeee" }] }, { "featureType": "water", "elementType": "geometry", "stylers": [{ "color": "#c9c9c9" }] }, { "featureType": "water", "elementType": "labels.text.fill", "stylers": [{ "color": "#9e9e9e" }] }], 7 retro: [{ "elementType": "geometry", "stylers": [{ "color": "#ebe3cd" }] }, { "elementType": "labels.text.fill", "stylers": [{ "color": "#523735" }] }, { "elementType": "labels.text.stroke", "stylers": [{ "color": "#f5f1e6" }] }, { "featureType": "administrative", "elementType": "geometry.stroke", "stylers": [{ "color": "#c9b2a6" }] }, { "featureType": "administrative.land_parcel", "elementType": "geometry.stroke", "stylers": [{ "color": "#dcd2be" }] }, { "featureType": "administrative.land_parcel", "elementType": "labels.text.fill", "stylers": [{ "color": "#ae9e90" }] }, { "featureType": "landscape.natural", "elementType": "geometry", "stylers": [{ "color": "#dfd2ae" }] }, { "featureType": "poi", "elementType": "geometry", "stylers": [{ "color": "#dfd2ae" }] }, { "featureType": "poi", "elementType": "labels.text.fill", "stylers": [{ "color": "#93817c" }] }, { "featureType": "poi.park", "elementType": "geometry.fill", "stylers": [{ "color": "#a5b076" }] }, { "featureType": "poi.park", "elementType": "labels.text.fill", "stylers": [{ "color": "#447530" }] }, { "featureType": "road", "elementType": "geometry", "stylers": [{ "color": "#f5f1e6" }] }, { "featureType": "road.arterial", "elementType": "geometry", "stylers": [{ "color": "#fdfcf8" }] }, { "featureType": "road.highway", "elementType": "geometry", "stylers": [{ "color": "#f8c967" }] }, { "featureType": "road.highway", "elementType": "geometry.stroke", "stylers": [{ "color": "#e9bc62" }] }, { "featureType": "road.highway.controlled_access", "elementType": "geometry", "stylers": [{ "color": "#e98d58" }] }, { "featureType": "road.highway.controlled_access", "elementType": "geometry.stroke", "stylers": [{ "color": "#db8555" }] }, { "featureType": "road.local", "elementType": "labels.text.fill", "stylers": [{ "color": "#806b63" }] }, { "featureType": "transit.line", "elementType": "geometry", "stylers": [{ "color": "#dfd2ae" }] }, { "featureType": "transit.line", "elementType": "labels.text.fill", "stylers": [{ "color": "#8f7d77" }] }, { "featureType": "transit.line", "elementType": "labels.text.stroke", "stylers": [{ "color": "#ebe3cd" }] }, { "featureType": "transit.station", "elementType": "geometry", "stylers": [{ "color": "#dfd2ae" }] }, { "featureType": "water", "elementType": "geometry.fill", "stylers": [{ "color": "#b9d3c2" }] }, { "featureType": "water", "elementType": "labels.text.fill", "stylers": [{ "color": "#92998d" }] }], 8 dark: [{ "elementType": "geometry", "stylers": [{ "color": "#212121" }] }, { "elementType": "labels.icon", "stylers": [{ "visibility": "off" }] }, { "elementType": "labels.text.fill", "stylers": [{ "color": "#757575" }] }, { "elementType": "labels.text.stroke", "stylers": [{ "color": "#212121" }] }, { "featureType": "administrative", "elementType": "geometry", "stylers": [{ "color": "#757575" }] }, { "featureType": "administrative.country", "elementType": "labels.text.fill", "stylers": [{ "color": "#9e9e9e" }] }, { "featureType": "administrative.land_parcel", "stylers": [{ "visibility": "off" }] }, { "featureType": "administrative.locality", "elementType": "labels.text.fill", "stylers": [{ "color": "#bdbdbd" }] }, { "featureType": "poi", "elementType": "labels.text.fill", "stylers": [{ "color": "#757575" }] }, { "featureType": "poi.park", "elementType": "geometry", "stylers": [{ "color": "#181818" }] }, { "featureType": "poi.park", "elementType": "labels.text.fill", "stylers": [{ "color": "#616161" }] }, { "featureType": "poi.park", "elementType": "labels.text.stroke", "stylers": [{ "color": "#1b1b1b" }] }, { "featureType": "road", "elementType": "geometry.fill", "stylers": [{ "color": "#2c2c2c" }] }, { "featureType": "road", "elementType": "labels.text.fill", "stylers": [{ "color": "#8a8a8a" }] }, { "featureType": "road.arterial", "elementType": "geometry", "stylers": [{ "color": "#373737" }] }, { "featureType": "road.highway", "elementType": "geometry", "stylers": [{ "color": "#3c3c3c" }] }, { "featureType": "road.highway.controlled_access", "elementType": "geometry", "stylers": [{ "color": "#4e4e4e" }] }, { "featureType": "road.local", "elementType": "labels.text.fill", "stylers": [{ "color": "#616161" }] }, { "featureType": "transit", "elementType": "labels.text.fill", "stylers": [{ "color": "#757575" }] }, { "featureType": "water", "elementType": "geometry", "stylers": [{ "color": "#000000" }] }, { "featureType": "water", "elementType": "labels.text.fill", "stylers": [{ "color": "#3d3d3d" }] }], 9 night: [{ "elementType": "geometry", "stylers": [{ "color": "#242f3e" }] }, { "elementType": "labels.text.fill", "stylers": [{ "color": "#746855" }] }, { "elementType": "labels.text.stroke", "stylers": [{ "color": "#242f3e" }] }, { "featureType": "administrative.locality", "elementType": "labels.text.fill", "stylers": [{ "color": "#d59563" }] }, { "featureType": "poi", "elementType": "labels.text.fill", "stylers": [{ "color": "#d59563" }] }, { "featureType": "poi.park", "elementType": "geometry", "stylers": [{ "color": "#263c3f" }] }, { "featureType": "poi.park", "elementType": "labels.text.fill", "stylers": [{ "color": "#6b9a76" }] }, { "featureType": "road", "elementType": "geometry", "stylers": [{ "color": "#38414e" }] }, { "featureType": "road", "elementType": "geometry.stroke", "stylers": [{ "color": "#212a37" }] }, { "featureType": "road", "elementType": "labels.text.fill", "stylers": [{ "color": "#9ca5b3" }] }, { "featureType": "road.highway", "elementType": "geometry", "stylers": [{ "color": "#746855" }] }, { "featureType": "road.highway", "elementType": "geometry.stroke", "stylers": [{ "color": "#1f2835" }] }, { "featureType": "road.highway", "elementType": "labels.text.fill", "stylers": [{ "color": "#f3d19c" }] }, { "featureType": "transit", "elementType": "geometry", "stylers": [{ "color": "#2f3948" }] }, { "featureType": "transit.station", "elementType": "labels.text.fill", "stylers": [{ "color": "#d59563" }] }, { "featureType": "water", "elementType": "geometry", "stylers": [{ "color": "#17263c" }] }, { "featureType": "water", "elementType": "labels.text.fill", "stylers": [{ "color": "#515c6d" }] }, { "featureType": "water", "elementType": "labels.text.stroke", "stylers": [{ "color": "#17263c" }] }], 10 aubergine: [{ "elementType": "geometry", "stylers": [{ "color": "#1d2c4d" }] }, { "elementType": "labels.text.fill", "stylers": [{ "color": "#8ec3b9" }] }, { "elementType": "labels.text.stroke", "stylers": [{ "color": "#1a3646" }] }, { "featureType": "administrative.country", "elementType": "geometry.stroke", "stylers": [{ "color": "#4b6878" }] }, { "featureType": "administrative.land_parcel", "elementType": "labels.text.fill", "stylers": [{ "color": "#64779e" }] }, { "featureType": "administrative.province", "elementType": "geometry.stroke", "stylers": [{ "color": "#4b6878" }] }, { "featureType": "landscape.man_made", "elementType": "geometry.stroke", "stylers": [{ "color": "#334e87" }] }, { "featureType": "landscape.natural", "elementType": "geometry", "stylers": [{ "color": "#023e58" }] }, { "featureType": "poi", "elementType": "geometry", "stylers": [{ "color": "#283d6a" }] }, { "featureType": "poi", "elementType": "labels.text.fill", "stylers": [{ "color": "#6f9ba5" }] }, { "featureType": "poi", "elementType": "labels.text.stroke", "stylers": [{ "color": "#1d2c4d" }] }, { "featureType": "poi.park", "elementType": "geometry.fill", "stylers": [{ "color": "#023e58" }] }, { "featureType": "poi.park", "elementType": "labels.text.fill", "stylers": [{ "color": "#3C7680" }] }, { "featureType": "road", "elementType": "geometry", "stylers": [{ "color": "#304a7d" }] }, { "featureType": "road", "elementType": "labels.text.fill", "stylers": [{ "color": "#98a5be" }] }, { "featureType": "road", "elementType": "labels.text.stroke", "stylers": [{ "color": "#1d2c4d" }] }, { "featureType": "road.highway", "elementType": "geometry", "stylers": [{ "color": "#2c6675" }] }, { "featureType": "road.highway", "elementType": "geometry.stroke", "stylers": [{ "color": "#255763" }] }, { "featureType": "road.highway", "elementType": "labels.text.fill", "stylers": [{ "color": "#b0d5ce" }] }, { "featureType": "road.highway", "elementType": "labels.text.stroke", "stylers": [{ "color": "#023e58" }] }, { "featureType": "transit", "elementType": "labels.text.fill", "stylers": [{ "color": "#98a5be" }] }, { "featureType": "transit", "elementType": "labels.text.stroke", "stylers": [{ "color": "#1d2c4d" }] }, { "featureType": "transit.line", "elementType": "geometry.fill", "stylers": [{ "color": "#283d6a" }] }, { "featureType": "transit.station", "elementType": "geometry", "stylers": [{ "color": "#3a4762" }] }, { "featureType": "water", "elementType": "geometry", "stylers": [{ "color": "#0e1626" }] }, { "featureType": "water", "elementType": "labels.text.fill", "stylers": [{ "color": "#4e6d70" }] }] 11 }; 12 const markerData = amm_frontend_obj.amm_save_marker_option 13 // Drawing shape object. 14 const markers = markerData.amm_marker_type ? JSON.parse(markerData.amm_marker_type) : ''; 15 const mapLatlngs = markerData.amm_marker_positions ? JSON.parse(markerData.amm_marker_positions) : ''; 4 16 5 var mapStyles = amm_frontend_obj.map_settings.map_style;6 var mapStyleType = amm_frontend_obj.map_settings.map_theme;7 var map_full_screen = amm_frontend_obj.map_settings.map_full_screen;8 var map_type_control = amm_frontend_obj.map_settings.map_type_control;9 var map_street_view = amm_frontend_obj.map_settings.map_street_view;10 var map_street_view = amm_frontend_obj.map_settings.map_street_view;11 var selectedStyle,12 standard = [],13 silver = [ {"elementType":"geometry","stylers":[{"color":"#f5f5f5"}]},{"elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"elementType":"labels.text.fill","stylers":[{"color":"#616161"}]},{"elementType":"labels.text.stroke","stylers":[{"color":"#f5f5f5"}]},{"featureType":"administrative.land_parcel","elementType":"labels.text.fill","stylers":[{"color":"#bdbdbd"}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#eeeeee"}]},{"featureType":"poi","elementType":"labels.text.fill","stylers":[{"color":"#757575"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#e5e5e5"}]},{"featureType":"poi.park","elementType":"labels.text.fill","stylers":[{"color":"#9e9e9e"}]},{"featureType":"road","elementType":"geometry","stylers":[{"color":"#ffffff"}]},{"featureType":"road.arterial","elementType":"labels.text.fill","stylers":[{"color":"#757575"}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#dadada"}]},{"featureType":"road.highway","elementType":"labels.text.fill","stylers":[{"color":"#616161"}]},{"featureType":"road.local","elementType":"labels.text.fill","stylers":[{"color":"#9e9e9e"}]},{"featureType":"transit.line","elementType":"geometry","stylers":[{"color":"#e5e5e5"}]},{"featureType":"transit.station","elementType":"geometry","stylers":[{"color":"#eeeeee"}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#c9c9c9"}]},{"featureType":"water","elementType":"labels.text.fill","stylers":[{"color":"#9e9e9e"}]} ],14 retro = [ {"elementType":"geometry","stylers":[{"color":"#ebe3cd"}]},{"elementType":"labels.text.fill","stylers":[{"color":"#523735"}]},{"elementType":"labels.text.stroke","stylers":[{"color":"#f5f1e6"}]},{"featureType":"administrative","elementType":"geometry.stroke","stylers":[{"color":"#c9b2a6"}]},{"featureType":"administrative.land_parcel","elementType":"geometry.stroke","stylers":[{"color":"#dcd2be"}]},{"featureType":"administrative.land_parcel","elementType":"labels.text.fill","stylers":[{"color":"#ae9e90"}]},{"featureType":"landscape.natural","elementType":"geometry","stylers":[{"color":"#dfd2ae"}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#dfd2ae"}]},{"featureType":"poi","elementType":"labels.text.fill","stylers":[{"color":"#93817c"}]},{"featureType":"poi.park","elementType":"geometry.fill","stylers":[{"color":"#a5b076"}]},{"featureType":"poi.park","elementType":"labels.text.fill","stylers":[{"color":"#447530"}]},{"featureType":"road","elementType":"geometry","stylers":[{"color":"#f5f1e6"}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#fdfcf8"}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#f8c967"}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#e9bc62"}]},{"featureType":"road.highway.controlled_access","elementType":"geometry","stylers":[{"color":"#e98d58"}]},{"featureType":"road.highway.controlled_access","elementType":"geometry.stroke","stylers":[{"color":"#db8555"}]},{"featureType":"road.local","elementType":"labels.text.fill","stylers":[{"color":"#806b63"}]},{"featureType":"transit.line","elementType":"geometry","stylers":[{"color":"#dfd2ae"}]},{"featureType":"transit.line","elementType":"labels.text.fill","stylers":[{"color":"#8f7d77"}]},{"featureType":"transit.line","elementType":"labels.text.stroke","stylers":[{"color":"#ebe3cd"}]},{"featureType":"transit.station","elementType":"geometry","stylers":[{"color":"#dfd2ae"}]},{"featureType":"water","elementType":"geometry.fill","stylers":[{"color":"#b9d3c2"}]},{"featureType":"water","elementType":"labels.text.fill","stylers":[{"color":"#92998d"}]} ],15 dark = [ {"elementType":"geometry","stylers":[{"color":"#212121"}]},{"elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"elementType":"labels.text.fill","stylers":[{"color":"#757575"}]},{"elementType":"labels.text.stroke","stylers":[{"color":"#212121"}]},{"featureType":"administrative","elementType":"geometry","stylers":[{"color":"#757575"}]},{"featureType":"administrative.country","elementType":"labels.text.fill","stylers":[{"color":"#9e9e9e"}]},{"featureType":"administrative.land_parcel","stylers":[{"visibility":"off"}]},{"featureType":"administrative.locality","elementType":"labels.text.fill","stylers":[{"color":"#bdbdbd"}]},{"featureType":"poi","elementType":"labels.text.fill","stylers":[{"color":"#757575"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#181818"}]},{"featureType":"poi.park","elementType":"labels.text.fill","stylers":[{"color":"#616161"}]},{"featureType":"poi.park","elementType":"labels.text.stroke","stylers":[{"color":"#1b1b1b"}]},{"featureType":"road","elementType":"geometry.fill","stylers":[{"color":"#2c2c2c"}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"color":"#8a8a8a"}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#373737"}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#3c3c3c"}]},{"featureType":"road.highway.controlled_access","elementType":"geometry","stylers":[{"color":"#4e4e4e"}]},{"featureType":"road.local","elementType":"labels.text.fill","stylers":[{"color":"#616161"}]},{"featureType":"transit","elementType":"labels.text.fill","stylers":[{"color":"#757575"}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#000000"}]},{"featureType":"water","elementType":"labels.text.fill","stylers":[{"color":"#3d3d3d"}]} ],16 night = [ {"elementType":"geometry","stylers":[{"color":"#242f3e"}]},{"elementType":"labels.text.fill","stylers":[{"color":"#746855"}]},{"elementType":"labels.text.stroke","stylers":[{"color":"#242f3e"}]},{"featureType":"administrative.locality","elementType":"labels.text.fill","stylers":[{"color":"#d59563"}]},{"featureType":"poi","elementType":"labels.text.fill","stylers":[{"color":"#d59563"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#263c3f"}]},{"featureType":"poi.park","elementType":"labels.text.fill","stylers":[{"color":"#6b9a76"}]},{"featureType":"road","elementType":"geometry","stylers":[{"color":"#38414e"}]},{"featureType":"road","elementType":"geometry.stroke","stylers":[{"color":"#212a37"}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"color":"#9ca5b3"}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#746855"}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#1f2835"}]},{"featureType":"road.highway","elementType":"labels.text.fill","stylers":[{"color":"#f3d19c"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#2f3948"}]},{"featureType":"transit.station","elementType":"labels.text.fill","stylers":[{"color":"#d59563"}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#17263c"}]},{"featureType":"water","elementType":"labels.text.fill","stylers":[{"color":"#515c6d"}]},{"featureType":"water","elementType":"labels.text.stroke","stylers":[{"color":"#17263c"}]} ],17 aubergine = [ {"elementType":"geometry","stylers":[{"color":"#1d2c4d"}]},{"elementType":"labels.text.fill","stylers":[{"color":"#8ec3b9"}]},{"elementType":"labels.text.stroke","stylers":[{"color":"#1a3646"}]},{"featureType":"administrative.country","elementType":"geometry.stroke","stylers":[{"color":"#4b6878"}]},{"featureType":"administrative.land_parcel","elementType":"labels.text.fill","stylers":[{"color":"#64779e"}]},{"featureType":"administrative.province","elementType":"geometry.stroke","stylers":[{"color":"#4b6878"}]},{"featureType":"landscape.man_made","elementType":"geometry.stroke","stylers":[{"color":"#334e87"}]},{"featureType":"landscape.natural","elementType":"geometry","stylers":[{"color":"#023e58"}]},{"featureType":"poi","elementType":"geometry","stylers":[{"color":"#283d6a"}]},{"featureType":"poi","elementType":"labels.text.fill","stylers":[{"color":"#6f9ba5"}]},{"featureType":"poi","elementType":"labels.text.stroke","stylers":[{"color":"#1d2c4d"}]},{"featureType":"poi.park","elementType":"geometry.fill","stylers":[{"color":"#023e58"}]},{"featureType":"poi.park","elementType":"labels.text.fill","stylers":[{"color":"#3C7680"}]},{"featureType":"road","elementType":"geometry","stylers":[{"color":"#304a7d"}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"color":"#98a5be"}]},{"featureType":"road","elementType":"labels.text.stroke","stylers":[{"color":"#1d2c4d"}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#2c6675"}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#255763"}]},{"featureType":"road.highway","elementType":"labels.text.fill","stylers":[{"color":"#b0d5ce"}]},{"featureType":"road.highway","elementType":"labels.text.stroke","stylers":[{"color":"#023e58"}]},{"featureType":"transit","elementType":"labels.text.fill","stylers":[{"color":"#98a5be"}]},{"featureType":"transit","elementType":"labels.text.stroke","stylers":[{"color":"#1d2c4d"}]},{"featureType":"transit.line","elementType":"geometry.fill","stylers":[{"color":"#283d6a"}]},{"featureType":"transit.station","elementType":"geometry","stylers":[{"color":"#3a4762"}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#0e1626"}]},{"featureType":"water","elementType":"labels.text.fill","stylers":[{"color":"#4e6d70"}]} ];18 19 switch( mapStyleType ) {20 case "silver":21 selectedStyle = silver;22 break;23 case "retro":24 selectedStyle = retro;25 break;26 case "dark":27 selectedStyle = dark;28 break;29 case "night":30 selectedStyle = night;31 break;32 case "aubergine":33 selectedStyle = aubergine;34 break;35 default:36 selectedStyle = standard;37 }38 39 var markerData = amm_frontend_obj.amm_save_marker_option40 // Drawing shape object.41 if ( markerData.amm_marker_positions ) {42 var mapType = JSON.parse( markerData.amm_marker_type );43 var mapLatlngs = JSON.parse( markerData.amm_marker_positions );44 }45 17 // Map controller object. 46 if ( markerData.amm_map_control) {47 var mapControl = JSON.parse( markerData.amm_map_control);18 if (markerData.amm_map_control) { 19 var mapControl = JSON.parse(markerData.amm_map_control); 48 20 } 49 21 50 22 // Finally land all the map on the map. 51 23 function initialize() { 52 // option from backend 53 var map_full_screen_status=false; 54 var map_type_control_status=false; 55 var map_street_view_status=false; 56 if(map_full_screen=='on'){ 57 map_full_screen_status=true; 58 } 24 const mapFullScreenStatus = mapSettings.map_full_screen ? true : false; 25 const mapTypeControlStatus = mapSettings.map_type_control ? true : false; 26 const mapStreetViewStatus = mapSettings.map_street_view ? true : false; 59 27 60 if(map_type_control=='on'){61 map_type_control_status=true;62 }28 const mapLat = (markerData.amm_map_control) ? mapControl[0].lat : 38.7520698; 29 const mapLng = (markerData.amm_map_control) ? mapControl[0].lng : 33.3604434; 30 const latlng = new google.maps.LatLng(mapLat, mapLng); 63 31 64 if(map_street_view=='on'){ 65 map_street_view_status=true; 66 } 67 var mapLat = ( markerData.amm_map_control ) ? mapControl[0].lat : 38.7520698; 68 var mapLng = ( markerData.amm_map_control ) ? mapControl[0].lng : 33.3604434; 69 var latlng = new google.maps.LatLng( mapLat, mapLng ); 70 var myOptions = { 71 zoom: ( markerData.amm_map_control ) ? mapControl[0].zoom : 5, 32 const mapOptions = { 33 zoom: (markerData.amm_map_control) ? mapControl[0].zoom : 5, 72 34 center: latlng, 73 map TypeControl: map_type_control_status,74 mapTypeControl Options: { style: google.maps.MapTypeControlStyle.DROPDOWN_MENU },35 mapId: 'frontmap', 36 mapTypeControl: mapTypeControlStatus, 75 37 navigationControl: true, 76 mapTypeId: mapStyles, 77 styles: selectedStyle, 78 fullscreenControl: map_full_screen_status, 79 streetViewControl: map_street_view_status, 38 mapTypeId: mapType, 39 fullscreenControl: mapFullScreenStatus, 40 streetViewControl: mapStreetViewStatus, 80 41 }; 81 // multimarkers array. 82 var multimarkers = []; 83 map = new google.maps.Map( document.getElementById('frontmap'), myOptions ); 84 if ( mapLatlngs ) { 42 43 const map = new google.maps.Map(document.getElementById('frontmap'), mapOptions); 44 const styledMapType = new google.maps.StyledMapType( 45 mapStyles[mapStyleType], 46 { name: mapStyleType } 47 ); 48 49 map.mapTypes.set("custom_style", styledMapType); 50 map.setMapTypeId("custom_style"); 51 52 if (mapLatlngs) { 53 const bounds = new google.maps.LatLngBounds(); 85 54 // Add map drawing tools. 86 mapLatlngs.forEach(function( latlg, i ) { 87 var geocoder = new google.maps.Geocoder; 88 var infowindow = new google.maps.InfoWindow; 55 mapLatlngs.forEach(function (latlg, i) { 56 const shapeType = markers[0].type[i]; 57 let latlngs = {}; 58 // var geocoder = new google.maps.Geocoder; 59 // var infowindow = new google.maps.InfoWindow; 89 60 var multipoint = []; 90 // MapType Marker. 91 if ( mapType[0].type[i] == 'marker' ) { 92 var latlngs = {lat: parseFloat(latlg.lat), lng: parseFloat(latlg.lng)}; 93 94 var marker = new google.maps.Marker( { 61 // markers. 62 if ('marker' == shapeType) { 63 latlngs = { lat: parseFloat(latlg.lat), lng: parseFloat(latlg.lng) }; 64 const marker = new google.maps.marker.AdvancedMarkerElement({ 95 65 position: latlngs, 96 66 map: map, 97 icon: latlg.img[0], 98 } ); 67 content: document.createElement('div') 68 }); 69 const img = document.createElement('img'); 99 70 100 google.maps.event.addListener( marker, 'click', function() { 101 infowindow = new google.maps.InfoWindow({ 102 content: '<div><strong>' + latlg.title[0] + '</strong><br /><a href="https://www.google.com/maps/search/?api=1&query=' + parseFloat( latlg.lat ) + ',' + parseFloat( latlg.lng ) + '&query_place_id=' + latlg.place_id + '" target="_blank">Get Direction</a></div>', 103 size: new google.maps.Size( 150, 50 ) 71 img.src = latlg.img[0]; 72 marker.content.appendChild(img); 73 bounds.extend(latlngs); 74 map.fitBounds(bounds); 75 76 google.maps.event.addListener(marker, 'click', function () { 77 const markerTitle = latlg.title || ''; 78 const infowindow = new google.maps.InfoWindow({ 79 content: '<div style="max-width:300px;"><strong style="display:block; padding:5px;">' + markerTitle + '</strong><a href="https://www.google.com/maps/search/?api=1&query=' + parseFloat(latlg.lat) + ',' + parseFloat(latlg.lng) + '&query_place_id=' + latlg.place_id + '" style="display:block; padding:5px;" target="_blank">Get Direction</a></div>', 80 size: new google.maps.Size(150, 50) 104 81 }); 105 infowindow.open( map, marker);106 } );82 infowindow.open(map, marker); 83 }); 107 84 } 108 // MapType polygon & polyline. 109 if ( mapType[0].type[i] == 'polygon' || mapType[0].type[i] == 'polyline' ) { 110 latlg.poly.forEach( function( pos, j ) { 111 multipoint.push( pos ); 85 // polygon & polyline markers. 86 if ('polygon' == shapeType || 'polyline' == shapeType) { 87 latlg.poly.forEach(function (pos, j) { 88 multipoint.push(pos); 89 latlngs = { lat: parseFloat(pos.lat), lng: parseFloat(pos.lng) }; 90 bounds.extend(latlngs); 91 map.fitBounds(bounds); 112 92 }); 113 93 114 94 var triangleCoords = multipoint; 115 95 // Construct the polygon. 116 var bermudaTriangle = new google.maps.Polygon( {96 var bermudaTriangle = new google.maps.Polygon({ 117 97 paths: triangleCoords, 118 strokeColor: latlg.fillcolor, 98 strokeColor: latlg.fillcolor, 119 99 strokeOpacity: 0.8, 120 100 strokeWeight: 3, 121 101 fillColor: latlg.fillcolor, 122 102 fillOpacity: 0.35 123 } );124 bermudaTriangle.setMap( map);103 }); 104 bermudaTriangle.setMap(map); 125 105 } 126 // MapType circle. 127 if ( mapType[0].type[i] == 'circle' ) { 128 var cityCircle = new google.maps.Circle( { 106 // circle markers. 107 if ('circle' == shapeType) { 108 latlngs = { lat: parseFloat(latlg.circle.lat), lng: parseFloat(latlg.circle.lng) }; 109 var cityCircle = new google.maps.Circle({ 129 110 strokeColor: latlg.fillcolor, 130 111 strokeOpacity: 0.8, … … 135 116 center: latlg.circle, 136 117 radius: latlg.radius 137 } );118 }); 138 119 } 139 // MapType rectangle. 140 if ( mapType[0].type[i] == 'rectangle' ) { 141 var rectangle = new google.maps.Rectangle( { 120 // Rectangle markers. 121 if ('rectangle' == shapeType) { 122 latlngs = { lat: parseFloat(latlg[shapeType].north + latlg[shapeType].south) / 2, lng: parseFloat(latlg[shapeType].east + latlg[shapeType].west) / 2 } 123 var rectangle = new google.maps.Rectangle({ 142 124 strokeColor: latlg.fillcolor, 143 125 strokeOpacity: 0.8, … … 147 129 map: map, 148 130 bounds: latlg.rectangle 149 } );131 }); 150 132 } 133 bounds.extend(latlngs); 134 map.fitBounds(bounds); 151 135 }); 152 136 } 153 137 } 154 155 google.maps.event.addDomListener( window, 'load', initialize ); -
add-multiple-marker/trunk/readme.txt
r2608577 r3433258 1 === Add Multiple Marker === 2 Contributors: girishpanchal, manishamakhija, nisargpandya, bhargavmehta, krishaweb 3 Tags: marker, custom marker, map marker, drawing tools, multiple marker, multi marker, map, google maps, multi location, shortcode 4 Requires at least: 4.4 5 Tested up to: 5.8.1 6 Stable tag: 1.2 7 License: GPLv2 or later 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html 1 === Multi Location Marker === 2 Plugin Name: Multi Location Marker 3 Plugin URI: https://wordpress.org/plugins/add-multiple-marker 4 Author: krishaweb 5 Author URI: https://krishaweb.com/ 6 Contributors: girishpanchal, manishamakhija, nisargpandya, krishaweb 7 Tags: locations, map, marker, google-maps, map-markers 8 Requires at least: 5.6 9 Tested up to: 6.9 10 Requires PHP: 8.2 11 Stable tag: 1.3 12 Copyright: (c) 2012-2026 KrishaWeb (info@krishaweb.com) 13 License: GPLv3 or later 14 License URI: http://www.gnu.org/licenses/gpl-3.0.html 9 15 10 Add Multiple Marker gives you feature to add multiple map locations on same map and display it in frontend using shortcode. 16 Multi Location Marker helps you add multiple map locations to a single map and display them on the frontend using a shortcode. 17 11 18 12 19 == Description == 13 20 14 Add Multiple Marker gives you various options to display multiple locations on single map by using different tools. It gives you various options like: 21 **Multi Location Marker** allows you to add and display multiple locations on a single Google Map using a shortcode. It helps you create an interactive and professional map for your website without any coding. 15 22 16 * Unlimited markers on single map 17 * Implement elegant styles on Google map 18 * Show your personalized title on markers 19 * Adjust zoom level 20 * Change marker image 21 * Drawing tools to define your service area 22 * Fetch your current geo-location and drop marker 23 * Get directions link in custom title 24 * Can delete marker and reset map 25 * Usage of Shortcode 23 You can manage unlimited markers from the admin panel, customize marker titles and icons, control map zoom and position, and define your service area using built-in drawing tools. The plugin also supports geo-location detection and direction links, making it easy for visitors to find and navigate to your locations. 24 25 Designed for simplicity and performance, Multi Location Marker is ideal for businesses that want to showcase stores, offices, or service coverage areas clearly and efficiently. 26 27 28 #### Key Features 29 30 * Add unlimited markers on a single Google Map 31 * Apply elegant Google Map styles 32 * Display custom titles on each marker 33 * Adjust map zoom level and center position 34 * Upload and use custom marker icons 35 * Use drawing tools to define and highlight your service area 36 * Automatically fetch your current geo-location and drop a marker 37 * Add a Get Directions link inside marker titles 38 * Reset the map or remove markers with a single click 39 * Display maps anywhere using a shortcode 40 * Works with pages, posts, and custom post types 41 26 42 27 43 == Installation == 28 44 29 This section describes how to install the plugin and get it working. 45 === From Admin Dashboard === 46 1. In your WordPress Dashboard go to "Plugins" -> "Add Plugin". 47 2. Search for "Multi Location Marker". 48 3. Install the plugin by pressing the "Install" button. 49 4. Activate the plugin by pressing the "Activate" button. 30 50 31 e.g. 32 33 1. Upload `add-multiple-marker.php` to the `/wp-content/plugins/` directory 34 2. Activate the plugin through the 'Plugins' menu in WordPress. 35 3. Go to Add Multiple Marker menu -> Map Integration and Enter Google Maps API Key. You can get Google Map API key from <a href="https://developers.google.com/maps/documentation/javascript/get-api-key">here</a>. 51 === Manually === 52 1. From wordpress directories, Upload `Multi Location Marker` to the `/wp-content/plugins/` directory 53 2. Now activate the plugin through the 'Plugins' menu in WordPress 36 54 37 55 38 56 == Frequently Asked Questions == 39 57 40 = How can I set the position of map? =58 = How do I set the map position? = 41 59 42 At whatever position(i.e latitude and longitude) you save your map on backend, your map will display likewise onfrontend.60 The map position is based on the latitude and longitude saved in the backend. Once saved, the same position will be displayed on the frontend. 43 61 44 = I have an idea for a great way to improve this plugin.=62 = Is there any limit on the number of markers? = 45 63 46 Great! I’d love to hear from you at <a href="mailto:support@krishaweb.com">support@krishaweb.com</a> 64 No. You can add unlimited markers on a single map. 65 66 = Can I highlight my service or business area? = 67 68 Yes. The plugin includes drawing tools that allow you to define and display your service or coverage area on the map. 69 70 = Does this plugin support automatic location detection? = 71 72 Yes. You can fetch your current geo-location and instantly place a marker. 73 74 = How do I display the map on my website? = 75 76 Simply copy the generated shortcode and paste it into any page, post, or widget area. 77 78 = I have an idea or feature request. How can I share it? = 79 80 We’d love to hear from you. Please contact us at <a href="mailto:support@krishaweb.com">support@krishaweb.com</a> 47 81 48 82 … … 53 87 3. Different Map Styling 54 88 89 55 90 == Changelog == 56 91 92 = 1.3 = 93 * Compatible with WordPress 6.8 94 * Fix - Title display issue 95 * Fix - Security Vulnerability 96 * Fix - Remove shape not working without page reload 97 * Fix - Display close (X) icon in sidebar hamburger menu 98 * Fix - Responsive view 99 57 100 = 1.2 = 58 * Made compatible with WordPress 5.8.1 and Bugs Fixes 59 101 * Made compatible with WordPress 5.8.1 and Bugs Fixes. 102 60 103 = 1.1 = 61 104 * Bugs Fixes
Note: See TracChangeset
for help on using the changeset viewer.