Jquery 单击图像时在关注点上缩放地图
我有一个HTML页面,有一个完整的窗口图像,一个显示一些中间点的传单地图,还有一个旋转木马,其中有一系列与感兴趣点对应的图像。兴趣点存储在geoJson文件中,如下所示:Jquery 单击图像时在关注点上缩放地图,jquery,leaflet,zooming,carousel,geojson,Jquery,Leaflet,Zooming,Carousel,Geojson,我有一个HTML页面,有一个完整的窗口图像,一个显示一些中间点的传单地图,还有一个旋转木马,其中有一系列与感兴趣点对应的图像。兴趣点存储在geoJson文件中,如下所示: var Points = { "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } }, "features": [ { "type": "Feature",
var Points = {
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "id": 1, "src": "..\/Foto\/Picture1.jpg", "descr": "Picture 1" }, "geometry": { "type": "Point", "coordinates": [ -157.6960968476377, 21.270789615399739 ] } },
{ "type": "Feature", "properties": { "id": 2, "src": "..\/Foto\/Picture2.jpg", "descr": "Picture 2" }, "geometry": { "type": "Point", "coordinates": [ -158.05145417649172, 21.528447405119081 ] } }
]
}
当我在地图或旋转木马上单击PoI时,整个窗口图像随之改变,并显示相应的图像。我还希望,当我点击旋转木马中的图像时,地图会缩放到相应的点。
这是HTML:
<div class="container-fluid" id="image-container">
<!-- BIG BACKGROUND IMAGE -->
<img id= "bigImg" src="../Foto/Pippo.jpg" alt="Pippo"> <!-- default image -->
<!-- HOME PAGE TITLE AND SUBTITLE -->
<div class="container-fluid" id="text-container">
<h1>Title</h1>
<p>SubTitle</p>
</div>
<div class="container-fluid" id="caption-container"></div>
<!-- MAP -->
<div class="map" id="mainMap"></div>
<!-- CAROUSEL -->
<div class="container-fluid" id="carousel-container">
<div class="row">
<div class="span12">
<div class="well">
<div id="myCarousel" class="carousel slide">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
</ol>
<!-- Carousel items -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<div class="row-fluid">
<div class="col-sm-1">
<div class="carousel-caption"><p>Picture 1</p></div>
<a href="#x" class="thumbnail"><img id="Picture1" class="photoThumbnail" src="../Foto/Picture1.jpg" alt="Picture 1" style="cursor:pointer" title="Picture 1"></a>
</div>
<div class="col-sm-1">
<div class="carousel-caption"><p>Picture 2</p></div>
<a href="#x" class="thumbnail"><img id="Picture2" class="photoThumbnail" src="../Foto/Picture2.jpg" alt="Picture 2" style="cursor:pointer" title="Picture "></a>
</div>
</div><!--/row-fluid-->
</div><!--/item-->
</div><!--/carousel-inner-->
</div><!--/myCarousel-->
</div><!--/well-->
</div>
</div>
</div>
</div>
标题
副标题
图1
图2
geoJson中的“descr”属性和“alt”属性相同。这是我的js:
$(".photoThumbnail").click(function(){
var imgsrc = this.src;
$("#bigImg").attr('src', imgsrc);
var imgalt = this.alt;
//from here not working
for (var i = 0; i < Points.length; i++) {
var PoI = Points[i];
var PoIdescr = PoI.feature.properties.descr;
if (PoIdescr = imgalt) {
var PoILatLon = PoI.feature.geometry.coordinates;
var PoILat = PoILatLon[0];
var PoILon = PoILatLon[1];
mainMap.setView([PoILat, PoILon], 12);
}
}
})
$(“.photo缩略图”)。单击(函数(){
var imgsrc=this.src;
$(“#bigImg”).attr('src',imgsrc);
var imgalt=this.alt;
//从这里开始不工作
对于(变量i=0;i
从“for”循环开始,它就不起作用,但我不知道如何解决它。谢谢您您的for循环是在Points.length上运行的,而不是Points.features.length,“features”是您要处理的数组