92 lines
3.0 KiB
PHTML
92 lines
3.0 KiB
PHTML
<?php if ($this->source == 'google'):?>
|
|
<div id="infogeo_photo">
|
|
<div id="legende-photo" style="display: block;">
|
|
Cliché à l'approche de l'adresse postale.
|
|
</div>
|
|
<div>
|
|
<img id="pp-cb-thumb" src="http://cbk0.google.com/cbk?output=thumbnail&w=150&h=69&ll=<?=$this->infos->GeoLat.','.$this->infos->GeoLon?>" width="300px" height="128px" />
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=<?=$this->googleKey?>"></script>
|
|
<script type="text/javascript">
|
|
function affichePhoto() {
|
|
<?php if ($this->infos->GeoPrecis < 7) {?>
|
|
var geoCoder = new GClientGeocoder;
|
|
geoCoder.getLocations("<?=$this->infos->AdresseNum.' '.
|
|
$this->infos->AdresseRue.' '.
|
|
$this->infos->CP.' '.
|
|
$this->infos->Ville?>", geoCodeCB);
|
|
<?php } else { ?>
|
|
var ll = new GLatLng(<?=$this->infos->GeoLat?>, <?=$this->infos->GeoLon?>);
|
|
doShowPanoData(ll);
|
|
<?php } ?>
|
|
}
|
|
|
|
function geoCodeCB(reponse) {
|
|
if (reponse &&
|
|
reponse.Status.code == 200 &&
|
|
reponse.Placemark.length == 1 &&
|
|
reponse.Placemark[0].AddressDetails.Accuracy > 5) {
|
|
var lat = reponse.Placemark[0].Point.coordinates[1];
|
|
var lon = reponse.Placemark[0].Point.coordinates[0];
|
|
var ll = new GLatLng(lat, lon);
|
|
doShowPanoData(ll);
|
|
}
|
|
}
|
|
|
|
function showPanoData(panoData) {
|
|
if (panoData.code != 200) {
|
|
return;
|
|
}
|
|
$('#pp-cb-thumb').replaceWith(
|
|
'<div id="pp-cb-thumb"><div class="left">' +
|
|
'<img src="http://maps.google.fr/cbk?output=tile&panoid=' +
|
|
panoData.location.panoId +
|
|
'&zoom=1&x=0&y=0&cb_client=maps_sv" />' +
|
|
'</div>' +
|
|
'<div class="right">' +
|
|
'<img src="http://maps.google.fr/cbk?output=tile&panoid=' +
|
|
panoData.location.panoId +
|
|
'&zoom=1&x=1&y=0&cb_client=maps_sv" />' +
|
|
'</div></div>');
|
|
|
|
$('#legende-photo' ).css('display','block');
|
|
$('#pp-cb-thumb' ).css('display','block');
|
|
}
|
|
|
|
function doShowPanoData(ll) {
|
|
var panoClient = new GStreetviewClient();
|
|
panoClient.getNearestPanorama(ll, showPanoData);
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
if ($('#pp-cb-thumb').length) {
|
|
affichePhoto();
|
|
}
|
|
});
|
|
</script>
|
|
<?php elseif ($this->source == 'mappy'):?>
|
|
<div><img id="pp-cb-thumb" width="300px" /></div>
|
|
<script src="<?=$this->lienJs?>"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(function() {
|
|
var photoService = new Mappy.api.visiocity.PhotoService();
|
|
var geo = new Mappy.api.geolocation.Geocoder();
|
|
|
|
var address = "<?=$this->adresse?>";
|
|
geo.geocode(address, function(result) {
|
|
photoService.search(result[0], "f", serviceHandler);
|
|
}, function(error) {});
|
|
|
|
var serviceHandler = function(result) {
|
|
if (result instanceof Mappy.api.visiocity.Frontage) {
|
|
var current = result.getCurrent();
|
|
var img = $('<img src="' + current.getURL(320, null) +
|
|
'" alt="' + current.getDescription() +
|
|
'" width="300px" />');
|
|
$('#pp-cb-thumb').replaceWith(img);
|
|
}
|
|
};
|
|
});
|
|
</script>
|
|
<?php endif;?> |