infobox avec vignette et info wikipedia

pour ZP, Flickr et WP sur single.php
This commit is contained in:
2017-02-26 19:50:29 +01:00
parent edcfd078cf
commit 8f5e96857a
4 changed files with 664 additions and 404 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -58,4 +58,17 @@ add_shortcode( 'zenphoto', 'zenphoto_handler' );
Media WP -> add_class_lightbox($content) -> img wordpress avec class="selector" Media WP -> add_class_lightbox($content) -> img wordpress avec class="selector"
---------
$coord()
array (size=9)
0 => string '45.584731' (length=9)
1 => string '7.318439' (length=8)
2 => string '2016-01-07_Renard_2905' (length=22)
3 => string '27868468454' (length=11)
4 => string 'Etonnante rencontre dans le parc du Grand Paradis (Italie) Alors que l'on redescendait du refuge après une belle rando, j'aperçoit goupil qui monte par le même chemin. On stoppe. Il s'arrête à notre hauteur avant de reprendre sa route tranquillement. Puis il s'arrête de nouveau pour prendre la pose un peu plus haut.' (length=335)
5 => string '<img id="lettrineImage" src="https://farm9.staticflickr.com/8176/27868468454_8f9afb79c4_m.jpg" alt=" " height="160" width="240" />' (length=130)
6 => null
7 => null
8 => null

View File

@@ -18,13 +18,35 @@ get_header();
the_content(); the_content();
//preprint($coord);
?> ?>
<?php //echo '<div id="map" style="display: ' . ((count($coord) > 0) ? "block" : "none") . ';"></div>'; <?php //echo '<div id="map" style="display: ' . ((count($coord) > 0) ? "block" : "none") . ';"></div>';
if (count($coord) > 0) { if (count($coord) > 0) {
//var_dump($coord); $b = array();
// Avec tous les titres, on crée la requete pour Wikipédia
for ($a = 0; $a < count($coord); $a++){
$short = $coord[$a][2]; // Titre
$b[] = $short;
}
$wiki = fmulticurl($b);
//On rajoute à $coord les données récupérées sur Wikipédia
if (count($coord) == count($wiki)) {
for ($c = 0; $c < count($wiki); $c++){
// [0] 1ere réponse, la plus pertinante
//array_push($coord[$c], $lettrine, $wiki[$c][1][0], $wiki[$c][2][0], $wiki[$c][3][0]);
array_push($coord[$c], $wiki[$c][1][0], $wiki[$c][2][0], $wiki[$c][3][0]);
//array_push($coord[$c], $wiki[$c][2][0], $wiki[$c][3][0]);
}
}
echo "après requete Wikipedia";
var_dump($coord);
?> ?>
@@ -55,6 +77,7 @@ get_header();
$( "button#hidemap" ).show(); $( "button#hidemap" ).show();
$( "button#showmap" ).hide(); $( "button#showmap" ).hide();
$( "i.ion-ios-location" ).show();
}); // button#showmap }); // button#showmap
@@ -62,6 +85,7 @@ get_header();
$( "#locations" ).toggle( "fast"); $( "#locations" ).toggle( "fast");
$( "button#hidemap" ).hide(); $( "button#hidemap" ).hide();
$( "button#showmap" ).show(); $( "button#showmap" ).show();
$( "i.ion-ios-location" ).hide();
data = true; data = true;
}); });
@@ -70,13 +94,28 @@ get_header();
var map; var map;
var markers = []; var markers = [];
var cnt; var cnt;
var locations = [ var locations = [
<?php <?php
$j = (count($coord) - 1); $j = (count($coord) - 1);
for ($i = 0; $i <= $j; $i++) { for ($i = 0; $i <= $j; $i++) {
//echo "['<h4>" . $coord[$i][2] . "</h4>', " . $coord[$i][0] . ", " . $coord[$i][1] . "]" . (($i<$j) ? "," : "")."\r\n"; //echo "['<h1>" . $coord[$i][2] . "</h1>','<p>" . $coord[$i][4] . "</p>', " . $coord[$i][0] . ", " . $coord[$i][1] . ",'" . $coord[$i][5] . "']" . (($i<$j) ? "," : "")."\r\n";
echo "['<span class\"infowindow\">" . $coord[$i][2] . "</span>', " . $coord[$i][0] . ", " . $coord[$i][1] . "]" . (($i<$j) ? "," : "")."\r\n"; echo "['<h1>" . addslashes($coord[$i][2]) . "</h1>','<p>" . addslashes($coord[$i][4]) . "</p>', " . $coord[$i][0] . ", " . $coord[$i][1] . ",'" . addslashes($coord[$i][5]) . "','" . addslashes($coord[$i][7]) . "','" . $coord[$i][8] . "']" . (($i<$j) ? "," : "")."\r\n";
} }
//array_push($coord, array(number_format($lat, 6), number_format($long, 6), $caption, $attach, $description, $thumbnail));
/*
locations[0] => $coord[2] => Titre (court)
locations[1] => $coord[4] => Description (long)
locations[2] => $coord[0] => Latitude
locations[3] => $coord[1] => Longitude
locations[4] => $coord[5] => <img "letrine">
locations[5] => $coord[7] => Texte Wikipedia
locations[6] => $coord[8] => Liens vers Wikipedia
$coord[3] => attachment
$coord[6] => <- requete wiki
*/
?> ?>
]; ];
@@ -85,6 +124,10 @@ get_header();
// Setup the different icons and shadows // Setup the different icons and shadows
var iconURLPrefix = 'https://maps.google.com/mapfiles/ms/icons/'; var iconURLPrefix = 'https://maps.google.com/mapfiles/ms/icons/';
var root = location.protocol + '//' + location.host;
var wikiImg = root + '/wordpress/wp-content/themes/CreatorThemeRes-child/images/wikipedia.png';
var wikiUrl = '<img src=\"' + wikiImg + '\" width=\"32\" height=\"32\" class=\"wiki\" />';
var icons = [ var icons = [
iconURLPrefix + 'red-dot.png', iconURLPrefix + 'red-dot.png',
iconURLPrefix + 'green-dot.png', iconURLPrefix + 'green-dot.png',
@@ -112,9 +155,10 @@ get_header();
var iconCounter = 0; var iconCounter = 0;
for (i = 0; i < locations.length; i++) { for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({ marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]), position: new google.maps.LatLng(locations[i][2], locations[i][3]),
map: map, map: map,
icon: icons[iconCounter] icon: icons[iconCounter],
title: locations[i][0]
}); });
markers.push(marker); markers.push(marker);
@@ -141,21 +185,46 @@ get_header();
} }
}); });
/*https://www.touraineverte.fr/google-maps-api-version-3/exemple-tutoriel-infobulles-infowindows/ajouter-infowindow-infobulle-marqueur-defaut-api-google-maps-version-3.html*/
/*
var contenuInfoBulle = '<h1>Cité Royale de Loches</h1>' +
'<h2>Royale et imprenable</h2>' +
'<img id="lettrineImage" src="https://static.touraineverte.fr/googlemapsapiversion3/photo_monument-loches.jpg" title="La cité royale de Loches" />' +
'<p>Remontez le temps pour découvrir l\'une des plus belles cités fortifiées de France.</p>' +
'<p>Le <b>DONJON</b>, haut de 36 mètres, a été construit par un comte d\'Anjou, Foulques Nerra, au début du XIe siècle. S\'il figure parmi les plus imposants de son époque en Europe, il est aussi l\'un des mieux conservés. Modèle d\'architecture militaire, il est transformé en prison royale par Louis XI.</p>' +
'<p>Le <b>LOGIS ROYAL</b> se trouve à proximité. Ce joyau de la Renaissance française, haut lieu de l\'Histoire de France, a été une résidence de prédilection de la dynastie des Valois. Sa façade ouverte en terrasse domine la ville et la vallée de l\'Indre. Le logis a accueilli notamment Jeanne d\'Arc, Agnès Sorel et Anne de Bretagne. Pour en savoir plus : <a href="http://www.cg37.fr/index.php?media=106" title="La cité royale de Loches" target="_parent">La cité royale de Loches</a></p>';
*/
/*
<h1>Titre</h1> =>
<h2>Sous-titre</h2>
Lettrine image
<p>Description</p>
*/
google.maps.event.addListener(marker, 'mousemove', (function (marker, i) { google.maps.event.addListener(marker, 'mousemove', (function (marker, i) {
return function () { return function () {
/*
var contentString = '<div id="content">'+ //var contenuInfoBulle = locations[i][0] + locations[i][4] + locations[i][1];
'<div id="siteNotice">'+ //var contenuInfoBulle = locations[i][0] + '<a href=\"' + locations[i][6] + '\">' + locations[i][4] + locations[i][5] + '</a>';
'</div>'+ var wikiLink = ''
'<h1 id="firstHeading" class="firstHeading">' + locations[i][0] + '</h1>'+ if (locations[i][6] != '') {
'<div id="bodyContent">'+ wikiLink = '<a href=\"' + locations[i][6] + '\" title=\"Plus sur Wikipedia...\">' + wikiUrl + '</a>'
'</div>'+ }
'</div>';
infowindow.setContent(contentString); var contenuInfoBulle = locations[i][0] + locations[i][4] + locations[i][1] + locations[i][5] + '<br />' + wikiLink;
*/
infowindow.setContent(locations[i][0]); /*
infowindow.open(map, marker); locations[0] => $coord[2] => Titre (court)
} locations[4] => $coord[5] => <img "letrine">
locations[1] => $coord[4] => Description (long)
locations[5] => $coord[7] => Texte Wikipedia
locations[6] => $coord[8] => Liens vers Wikipedia
*/
infowindow.setContent(contenuInfoBulle);
infowindow.open(map, marker);
}
})(marker, i)); })(marker, i));
iconCounter++; iconCounter++;
@@ -176,12 +245,13 @@ get_header();
} }
setTimeout(function() { setTimeout(function() {
infowindow.setContent(locations[cnt][0]); /*infowindow.setContent(locations[cnt][0]);*/
infowindow.setContent(contenuInfoBulle);
infowindow.open(map, markers[cnt]); infowindow.open(map, markers[cnt]);
}, 300); }, 300);
} //jumpToMarker } //jumpToMarker
</script> </script>

View File

@@ -106,7 +106,8 @@ $query_images = new WP_Query($query_images_args);
if (count($coord) > 0) { if (count($coord) > 0) {
//var_dump($coord); echo "avant requete Wikipedia";
var_dump($coord);
/* /*
0 => 0 =>
array (size=6) array (size=6)
@@ -136,7 +137,8 @@ $query_images = new WP_Query($query_images_args);
} }
} }
//var_dump($coord); echo "après requete Wikipedia";
var_dump($coord);
?> ?>
<script type="text/javascript"> <script type="text/javascript">