gpt4 book ai didi

javascript - 通过 Flickr 混搭 Google map 和照片

转载 作者:行者123 更新时间:2023-11-30 18:03:23 26 4
gpt4 key购买 nike

我在使用这个小脚本时遇到了一些问题,它允许我使用 flickr 的谷歌地图和照片创建混搭。它创建了一张从罗马到米兰的简单 map ,然后根据地理标记从 flickr 请求十张图像。所以最后,它将每张照片定位为从谷歌获取的标记。

但是我不明白我做错了什么。有人有什么想法吗?

<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Mappa+info</title>
<style type="text/css">
html, body { margin:0; padding:0; width:100%; height:100%; }
body { background:#FFFFFF; color:#000000; font-family:Arial, Helvetica, sans-serif; font-size:12px; line-height:150%; text-align:center;}
#map { width:100%; height:100%; }
input { width:250px; }
</style>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyC0HAM8PI7RMqUiSm444JDehtJOsWBtE_E&sensor=true"></script>
<script type="text/javascript">

var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var map;
var latlongp1;
var latlongp2;

function initialize() {

calcRoute();
directionsDisplay = new google.maps.DirectionsRenderer();
var myOptions = {
zoom:7,
mapTypeId: google.maps.MapTypeId.ROADMAP
}

map = new google.maps.Map(document.getElementById("map"), myOptions);

directionsDisplay.setMap(map);

var latlonbounds=map.getBounds(); alert(latlonbounds.getNorthEast());
latlongp1=latlonbounds.getNorthEast();
latlongp2=latlonbounds.getSouthWest();


posizionaFoto();


}

function calcRoute() {
var partenza = "Roma";
var arrivo = "Milano";
var request = {
origin:partenza,
destination:arrivo,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
}

function posizionaFoto(){

//richiesta flickr
var bbox=latlongp1.lat()+","+latlongp1.lng()+","+latlongp2.lat()+","+latlongp2.lon();
var apikey="48770d8235b7055d803bd8d913304624";
var url="http://api.flickr.com/services/rest/?"+
"method=flickr.photos.search"+
"&format=json"+
"&per_page=10"+
"&extras=geo"+
"&bbox="+bbox+
"&nojsoncallback=1"+
"&api_key="+apikey;

var client =new XMLHttpRequest();
client.open("GET",url,true);
client.send();
client.onreadystatechange=function(){

if((client.readyState==4)&&(client.status==200)){
var data=JSON.parse(client.responseText);
var photos=data.photos;
//creazione marker per foto
var photo=photos.photo;
var aPhoto;
var url;
for(var k in photo){
aPhoto=photo[k];
var markerIcon=new google.maps.MarkerImage("http://farm"+aPhoto.farm+"static.flickr.com/"+aPhoto.server +"/"+aPhoto.id+"_"+aPhoto.secret+"_b.jpg");
var latLonphoto=new google.maps.LatLng(aPhoto.latitude,aPhoto.longitude);
var markerOptions={
map:map,
position:latLonphoto,
icon:markerIcon
};
marker=new google.maps.Marker(markerOptions);
}
}
};
}

window.onload = initialize;
</script>
</head>
<body>
<div id="map"></div>
</body>

最佳答案

在设置 markerIcon 的行中有“.”在“静态”之前丢失

关于javascript - 通过 Flickr 混搭 Google map 和照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16371361/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com