Javascript.RU

Создать новую тему Ответ
 
Опции темы Искать в теме
  #1 (permalink)  
Старый 30.09.2016, 10:05
veg veg вне форума
Аспирант
Отправить личное сообщение для veg Посмотреть профиль Найти все сообщения от veg
 
Регистрация: 05.04.2012
Сообщений: 43

Карта под спойлером изменяет масштаб
Запихивая карту под спойлер, изменяется масштаб.
Юзаю leafletsjs

Собсна весь код:
Бери, вставляй, проверяй
<link rel="stylesheet" href="http://stopom.ru/wp-content/themes/wt_tera/maps/leaflet.css" />
<script src="http://stopom.ru/wp-content/themes/wt_tera/maps/leaflet.js"></script>

<script type="text/javascript">var coords = [
L.latLng(43.47103,40.5337),
L.latLng(43.47155,40.53335),
L.latLng(43.47174,40.53262),];</script>
<details>
<summary>Текст</summary>
<div id="map" style=" width: 720px; height: 480px;"></div>
</details>

<script type="text/javascript">

var map = L.map('map');
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '',
center: [43.47392,40.50802],
maxZoom: 15,
scrollWheelZoom:false,
}).addTo(map);

var line = L.polyline(coords, {
distanceMarkers: { showAll: 10, cssClass: 'some-other-class' }
});
var line = L.polyline(coords, {
distanceMarkers: { lazy: true }
});
L.marker([43.47509,40.5064]).addTo(map)
.bindPopup('Озеро Малая Рица')
.openPopup();
map.fitBounds(line.getBounds());
map.addLayer(line);
L.marker([43.47103,40.5337]).addTo(map)
.bindPopup('Озеро Рица')
.openPopup();
map.fitBounds(line.getBounds());
map.addLayer(line);

</script>

Без спойлера, отображается как надо.
Как сделать, чтобы спойлер не менял масштаб?

Последний раз редактировалось veg, 30.09.2016 в 10:23.
Ответить с цитированием
  #2 (permalink)  
Старый 30.09.2016, 11:54
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,075

leaflet and details
veg,
<!DOCTYPE html>

<html>
<head>
  <title>Untitled</title>
  <meta charset="utf-8">
   <style type="text/css">
  summary:focus{
    outline:  none;
  }

  </style>
</head>

<body>
<link rel="stylesheet" href="http://stopom.ru/wp-content/themes/wt_tera/maps/leaflet.css" />
<script src="http://stopom.ru/wp-content/themes/wt_tera/maps/leaflet.js"></script>


<script type="text/javascript">
var coords = [
L.latLng(43.47103,40.5337),
L.latLng(43.47155,40.53335),
L.latLng(43.47174,40.53262),];</script>
<details open="">
<summary>Текст</summary>
<div id="map" style=" width: 720px; height: 480px;"></div>
</details>

<script type="text/javascript">

var map = L.map('map');
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '',
center: [43.47392,40.50802],
maxZoom: 14,
scrollWheelZoom:false,
}).addTo(map);

var line = L.polyline(coords, {
distanceMarkers: { showAll: 10, cssClass: 'some-other-class' }
});
var line = L.polyline(coords, {
distanceMarkers: { lazy: true }
});
L.marker([43.47509,40.5064]).addTo(map)
.bindPopup('Озеро Малая Рица')
.openPopup();
map.fitBounds(line.getBounds());
map.addLayer(line);
L.marker([43.47103,40.5337]).addTo(map)
.bindPopup('Озеро Рица')
.openPopup();
map.fitBounds(line.getBounds());
map.addLayer(line);
document.querySelector('[open]').removeAttribute('open');
</script>


</body>
</html>
Ответить с цитированием
Ответ



Опции темы Искать в теме
Искать в теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Не открывается текст под спойлером MASTER31 Общие вопросы Javascript 7 28.09.2014 15:53
Что означает [^] riva Общие вопросы Javascript 26 07.08.2014 20:42