我有一个传单地图,显示从GeoJSON渲染的公共艺术作品的点.在地图旁边,我创建了一个来自相同GeoJSON数据的片段列表,并且希望能够从地图外部的列表中单击某个项目,并在地图上显示相关标记的弹出窗口.
如何通过点击事件将项目列表链接到各自的标记?
我的map.js文件如下所示:
var map;
var pointsLayer;
$(document).ready(function () {
map = new L.Map('mapContainer');
var url = 'http://{s}.tiles.mapbox.com/v3/mapbox.mapbox-streets/{z}/{x}/{y}.png';
var copyright = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade';
var tileLayer = new L.TileLayer(url, {
attribution: copyright
});
var startPosition = new L.LatLng(41.883333, - 87.633333);
map.on('load', function (e) {
requestUpdatedPoints(e.target.getBounds())
});
map.setView(startPosition, 13).addLayer(tileLayer);
map.on('moveend', function (e) {
requestUpdatedPoints(e.target.getBounds())
})
});
function requestUpdatedPoints(bounds) {
$.ajax({
type: 'GET',
url: '/SeeAll',
dataType: 'json',
data: JSON.stringify(bounds),
contentType: 'application/json; …Run Code Online (Sandbox Code Playgroud)