-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfront-page.php
91 lines (73 loc) · 2.02 KB
/
front-page.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* Home Template
*
* This template is used to display the home page of the site.
*
* Learn More
*
* https://developer.wordpress.org/themes/basics/template-hierarchy/
*
**/
// Get *all* the Maps!
$Map = new Waymark_Map();
$overlays = [];
foreach ($Map->get_posts() as $map) {
// Get Map data
$map_data = get_post_meta($map->ID, 'waymark_map_data', true);
// Convert to Array
$map_data = Waymark_GeoJSON::string_to_feature_collection($map_data);
// Merge recursively
if (is_array($overlays) && sizeof($overlays)) {
$overlays = array_merge_recursive($overlays, Waymark_GeoJSON::features_by_overlay_type($map_data));
}
}
get_header();?>
<!-- All Maps -->
<div class="row">
<article class="container-fluid">
<?php echo do_shortcode('[Waymark shortcode_header="0" loaded_callback="map_first_home" map_hash="home" ]'); ?>
</article>
</div>
<?php get_sidebar();?>
<script>
/**
* Callback function for the Map
*
* This **JavaScript** function is called when Waymark has finished loading to appropriate Shortcode.
*
* It is passed a single argument - the Waymark_Instance object.
*
* Learn More
*
* https://www.waymark.dev/docs/callback-function/
*
**/
function map_first_home(Waymark_Instance) {
<?php
$i = 1;
foreach ($Map->get_posts() as $map) {
// Get Map data
$map_data = get_post_meta($map->ID, 'waymark_map_data', true);
// Setting for Embed / Fetch via XJAX (Waymark Settings > Maps > Collections)
// Embed
if ('embed' === Waymark_Config::get_setting('misc', 'collection_options', 'load_method')) {
//Modify map data
$map_data = Waymark_Helper::add_map_link_to_description($map->ID, $map->post_title, $map_data);
echo 'Waymark_Instance.load_json(' . $map_data . ');' . "\n";
// AJAX
} else {
//Reset view (last map only)
if ($i == sizeof($Map->get_posts())) {
$reset_view = 'true';
} else {
$reset_view = 'false';
}
echo 'waymark_load_map_data(Waymark_Instance, ' . $map->ID . ', true, ' . $reset_view . ');' . "\n";
}
$i++;
}
?>
}
</script>
<?php get_footer();?>