У меня есть несколько достопримечательностей с несколькими маркерами. Я хочу нарисовать путь маршрута между каждым маркером. В functions.php (wordpress) у меня есть массив. Вы найдете этот массив в $bicycleGeoCode
, а затем найдете 'bicycles' => array(array)
.
Смотрите скриншот моего многократного маркера
function chatbot_cycle_pass_enqueue_scripts(){
global $cmb_booking, $cmb_review, $cmb_store, $cmb_user, $contentLang;
//load full version or minified version of javascript
//$prefix = WP_DEBUG ? '' : '.min';
$prefix = NULL;
// Google Fonts
//wp_enqueue_style( 'natosans', '//fonts.googleapis.com/css?family=Noto+Sans:400,700');
// Theme CSS files
$GoogleMapsSRC = "https://maps.googleapis.com/maps/api/js";
//key=YOUR_API_KEY&callback=initMap
//http_build_query()
$GoogleMapsQuery = array();
$GoogleMepsApi = GetAdminOptions("google_maps_api");
if($GoogleMepsApi != FALSE)
$GoogleMapsQuery["key"] = $GoogleMepsApi;
$GoogleMapsQuery["libraries"] = "geometry";
$GoogleMapsQuery["language"] = $contentLang;
$GoogleMapsQuery = http_build_query(apply_filters("googlemapsapi", $GoogleMapsQuery));
$GoogleMapsSRC .= (!empty($GoogleMapsQuery))? "?".$GoogleMapsQuery : "";
wp_register_script("GoogleMaps2", $GoogleMapsSRC, false, THEME_VERSION );
wp_register_script( 'GoogleMapsInfoWindow2', TemplateURL . "/cycle_assets/infobox{$prefix}.js", array( "GoogleMaps2" ) , THEME_VERSION, true );
wp_register_script( 'BicycleGeoCodeAPI2', TemplateURL . "/js/chatbot_cycle_pass_geocode.js", array( "GoogleMaps2", 'GoogleMapsInfoWindow2', 'jquery') , THEME_VERSION, true );
$bicycleGeoCode = apply_filters("bicycle_geocode_ajax_object", array(
'ajaxurl' => admin_url('admin-ajax.php'),
'home_url' => site_url(),
'center' => array( "latitude" => 34.695094, "longitude" => 135.193806),
'marker_bicycle' => TemplateURL . "/cycle_assets/bicycle_marker.png",
'marker_user' => TemplateURL . "/img/marker-user.png",
'close_btn' => TemplateURL . "/cycle_assets/btn_close.gif",
'tip' => TemplateURL . "/cycle_assets/tipbox.png",
'GeoCodelocationDataAlert' => __("Please check your location sharing settings.", 'tebura'),
'locationNotSupported' => __("Your Browser/Device doesn't support Geo Location API.",'tebura'),
'locationDataAlert' => __("Please Check Your Location Sharing Settings.", 'tebura'),
'locationDataTimeOutAlert' => __("Request Timeout during processing your location data.<br>Please Reload Your Browser",'tebura'),
'locationDataPositionUnavailableAlert' => __("Your Position is Unavailable.<br>Please Activate Your GPS And Location Services And Reload The Page.",'tebura'),
'locationDataPermissionDeniedAlert' => __("Your Location Sharing Settings Is Blocked.<br>Please Change Your Location Sharing Settings And Reload The Page.",'tebura'),
'locationDataUnknownErrorAlert' => __("An Unknown Error Occurred.<br>Please Try Again After Sometime.", 'tebura'),
'bookingButtonText' => __("Click here to book now.", 'tebura'),
'storeDistanceTimeText' => __("Nearest baggage claim distance is {0} and it would take approximate {1} to get there.", 'tebura'),
'bicycles' => array(
array(
'ImgURL' => TemplateURL . '/cycle_assets/cycles/img_port1.jpg',
'title' => 'Shibuya City Test',
'Address' => 'Japan, 〒151-0063 Tōkyō-to, Shibuya City, Tomigaya, 1-chōme−3−8 第22SYビル',
'Time' => '24時間',
'Max' => '15 Available',
'latitude' => '35.669187',
'longitude' => '139.689099'
),
array(
'ImgURL' => TemplateURL . '/cycle_assets/cycles/img_port1.jpg',
'title' => '三宮駅前',
'Address' => '神戸市中央区三宮町1丁目10',
'Time' => '24時間',
'Max' => '15 Available',
'latitude' => '34.693094',
'longitude' => '135.193806'
),
array(
'ImgURL' => TemplateURL . '/cycle_assets/cycles/img_port2.jpg',
'title' => '元町駅前',
'Address' => '神戸市中央区元町高架通',
'Time' => '24時間',
'Max' => '15 Available',
'latitude' => '34.689873',
'longitude' => '135.188265'
), array(
'ImgURL' => TemplateURL . '/cycle_assets/cycles/img_port3.jpg',
'title' => 'ハーバーランド',
'Address' => '神戸市中央区東川崎町1丁目8',
'Time' => '24時間',
'Max' => '15 Available',
'latitude' => '34.680873',
'longitude' => '135.183115'
), array(
'ImgURL' => TemplateURL . '/cycle_assets/cycles/img_port4.jpg',
'title' => '北野工房のまち',
'Address' => '神戸市中央区中山手通3丁目17',
'Time' => '24時間',
'Max' => '15 Available',
'latitude' => '34.695887',
'longitude' => '135.187096'
), array(
'ImgURL' => TemplateURL . '/cycle_assets/cycles/img_port5.jpg',
'title' => '三宮アーバンエースビル前',
'Address' => '神戸市中央区小野柄通4丁目1',
'Time' => '24時間',
'Max' => '14 Available',
'latitude' => '34.694899',
'longitude' => '135.199250'
), array(
'ImgURL' => TemplateURL . '/cycle_assets/cycles/img_port6.jpg',
'title' => 'JR新神戸駅前',
'Address' => '神戸市中央区加納町1丁目3',
'Time' => '24時間',
'Max' => '18 Available',
'latitude' => '34.706077',
'longitude' => '135.195554'
), array(
'ImgURL' => TemplateURL . '/cycle_assets/cycles/img_port7.jpg',
'title' => '神戸市役所前',
'Address' => '神戸市中央区加納町6-5-1',
'Time' => '24時間',
'Max' => '14 Available',
'latitude' => '34.689935',
'longitude' => '135.195788'
), array(
'ImgURL' => TemplateURL . '/cycle_assets/cycles/img_port8.jpg',
'title' => '北野町中公園',
'Address' => '神戸市中央区北野町3丁目10',
'Time' => '24時間',
'Max' => '5 Available',
'latitude' => '34.701062',
'longitude' => '135.189503'
), array(
'ImgURL' => TemplateURL . '/cycle_assets/cycles/img_port9.jpg',
'title' => 'メリケンパーク',
'Address' => '神戸市中央区波止場町2',
'Time' => '24時間',
'Max' => '5 Available',
'latitude' => '34.681460',
'longitude' => '135.187654'
), array(
'ImgURL' => TemplateURL . '/cycle_assets/cycles/img_port10.jpg',
'title' => '兵庫県立美術館前',
'Address' => '神戸市中央区脇浜海岸通1丁目1−1',
'Time' => '24時間',
'Max' => '5 Available',
'latitude' => '34.699897',
'longitude' => '135.218344'
)
),
));
wp_enqueue_script( "GoogleMaps2" );
if ( is_page_template( 'chatbot_cycle_pass.php' ) )
wp_localize_script( 'BicycleGeoCodeAPI2', 'bicycleGeoCode', $bicycleGeoCode );
if ( is_page_template( 'chatbot_cycle_pass.php' ) ){
wp_enqueue_script( 'GoogleMapsInfoWindow2' );
wp_enqueue_script( 'BicycleGeoCodeAPI2' );
}
// debug_dump(get_page_template_slug());
}
add_action( 'wp_enqueue_scripts', 'chatbot_cycle_pass_enqueue_scripts', 11);