-
Notifications
You must be signed in to change notification settings - Fork 2
/
gtm_tagged_media_map.php
92 lines (82 loc) · 3.73 KB
/
gtm_tagged_media_map.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
92
<?php
//debug(__FILE__ .'-'. __LINE__. ': ' . $shortcode_attrs['category']);
if (isset($category)) {
echo "<script type='text/javascript'>var category = '$category' ;</script>";
}
$categories = gtm_category_names_for_geotagged_photos();
?>
<H1>Geotagged media</H1>
<div id="source-maps-radios">
<label><input type="radio" name="source_map" value="OSM" checked>OSM</label>
<label><input type="radio" name="source_map" value="BingMaps">BingMaps</label>
<label><input type="radio" name="source_map" value="ESRI-XYZ">ESRI-XYZ</label>
<label><input type="radio" name="source_map" value="TileWMS">TileWMS</label>
<label><input type="radio" name="source_map" value="ThunderForest">ThunderForest</label>
<label><input type="radio" name="source_map" value="Google">Google</label>
<label><input type="radio" name="source_map" value="MapBox">MapBox</label>
</div>
<div id="map-thumbnails">
<label><input type="checkbox" name="show_all_in_popovers" value="true">Show all photos in popups</label>
</div>
<div id="categories-filter">
<label>Filter by category</label>
<select name="categories_filter">
<option value="">All</option>
<?php foreach ($categories as $name) : ?>
<?php ?>
<option value="<?php echo $name ?>" <?php echo(isset($category) && $category == $name ? " selected" : "") ?> ><?php echo $name ?></option>
<?php endforeach; ?>
</select>
</div>
<P id='gtm-media-info'>Please wait while the map with the points for the geocoded media loads...</P>
<P class="gtm-highlight" style="display:none">Click on every square to show a popup with a thumbnail for the photo. Clicking on the thumbnail inside the popup will take you to the 'Edit Photo' view.</P>
<label>Map search
<input id="map_search" type="text" name="geoname_search" style="width: 400px"
placeholder="Input place name, street, etc...">
</label>
<div id="map" class="gtm-map">
</div>
<div style="display:none" id="popup_wrapper">
<!-- Popup in which the point details appears when clicking -->
<div id="popup" class="popup" title="Here is:"></div>
</div>
<script type="text/javascript">
jQuery(document).ready(function ($) {
$('#map_search').autocomplete({
source: function (request, response) {
console.log('map search autocomplete!', request, response);
$.getJSON(
ajaxurl + "?action=geocode_search",
{geoname: $('#map_search').val()},
response
);
console.log(response);
},
select: function (evt, ui) {
evt.preventDefault();
var input = $(evt.target);
console.log('select', evt, ui);
console.log('selected', ui.item.name);
$(input).attr('value', ui.item.name);
$(input).attr('lat', ui.item.lat);
$(input).attr('long', ui.item.long);
console.log('input', input, $(input).attr('lat'));
moveToNewCenter($('#map').data('map'), input.attr('lat'), input.attr('long'));
return false;
},
response: function (evt, ui) {
console.log('response', evt, ui);
$(this).data('ui-autocomplete')._renderItem = function (ul, item) {
newLink = $('<a>' + item.name + '</a>');
newListItem = $('<li>').attr('lat', item.lat);
$(newListItem).attr('long', item.long);
//$(newListItem).data('item',item);
return $(newListItem)
.append(newLink)
.appendTo(ul);
};
}
});
})
;
</script>