MapBoxgl에서 작업 중이며 여러 표식을 추가하고 싶습니다. 여기 MapBox 표시 자 확대/축소시 이동
내 index.html을 수 있습니다 :<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link href=" /assets/css/bootstrap.min.css " rel="stylesheet" />
<link href=" /assets/css/mapbox-gl.css " rel="stylesheet" />
<link href=" /assets/css/main.css " rel="stylesheet" />
</head>
<body>
<div id="map"></div>
<script src="/assets/js/mapbox-gl.js"></script>
<script src="/assets/js/map-style.js"></script>
</body>
</html>
이이다지도 - style.js :
#map { position:absolute; top:0; bottom:0; width:100% }
.markers {
display: absolute;
border: none;
border-radius: 50%;
cursor: pointer;
padding: 0;
}
:
var map = new mapboxgl.Map({
container: 'map',
center: [57.3221, 33.5928],
zoom: 5,
style: style
});
var geojson = {
type: 'FeatureCollection',
features: [{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [30.61, 46.28]
},
properties: {
title: 'point 1',
description: 'point 1 Description',
message: 'point1',
iconSize: [25, 25]
}
},
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [30.62, 46.2845]
},
properties: {
title: 'point 2',
description: 'point 2 Description',
message: 'point 2',
iconSize: [25, 25]
}
}]
};
map.on('load', function() {
// add markers to map
geojson.features.forEach(function(marker) {
// create a DOM element for the marker
var el = document.createElement('div');
el.className = 'markers';
el.style.backgroundImage = 'url(assets/marker-azure.png)';
//el.style.width = marker.properties.iconSize[0] + 'px';
el.style.height = marker.properties.iconSize[1] + 'px';
el.addEventListener('click', function() {
window.alert(marker.properties.message);
});
// add marker to map
new mapboxgl.Marker(el)
.setLngLat(marker.geometry.coordinates)
.addTo(map);
});
});
그리고 다음 main.css가지도에 관련된 부분과 마커입니다
내 문제는 마커에 너비 속성을 추가하면 해당 아이콘이 올바르게 표시되지만 비트가 늘어납니다. 룽 조정하고 아래 그림과 같이 줌에 이동 : width 속성이 제거되면 한편
, 그들은 바로 이곳에 있고 확대에 이동하지 않습니다,하지만 그들은 매우 신장되어 사실 넓은 화면으로 (아래 이미지) :
그것은 내가 부트 스트랩을 사용했습니다 주목할만한입니다. 이 이유가 될 수 있습니까? 그렇지 않다면 무엇이 문제입니까?
감사