javascript Yandex映射Api
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Yandex映射Api相关的知识,希望对你有一定的参考价值。
$(function () {
if ($("#mapContacts").length > 0)
{
ymaps.ready(function () {
var map = new ymaps.Map("mapContacts", {
center: [40.873556127486474, 50.649276543971425],
zoom: 5,
controls: ['zoomControl', 'typeSelector', 'fullscreenControl']
});
var iconSVG = {
iconLayout: 'default#image',
iconImageHref: '/local/templates/act/assets/images/ico/pin.svg',
iconImageSize: [30, 41],
iconImageOffset: [-15, -42]
};
map.behaviors.disable("scrollZoom");
myCollection = new ymaps.GeoObjectCollection();
$('.branch-row .branch-item').each(function () {
var coords = $(this).data('coords').split(','),
address = $(this).data('address');
placemark = new ymaps.Placemark(coords, {
balloonContent: address,
}, iconSVG);
myCollection.add(placemark);
var $mapAddress = $(this).find('.mapAddress');
$mapAddress.on('click', function (event) {
map.setCenter(coords, 18, {duration: 500});
if (event.originalEvent) {
$('html, body').animate({scrollTop: $('#mapContacts').offset().top}, 700);
}
});
});
var $mainAddress = $('#mainAddress'),
coords = $mainAddress.data('coords').split(','),
address = $mainAddress.data('address');
myCollection.add(new ymaps.Placemark(coords, {
balloonContent: address
}, iconSVG));
myCollection.add(placemark);
$mainAddress.on('click', function (event) {
map.setCenter(coords, 18, {duration: 500});
if (event.originalEvent) {
$('html, body').animate({scrollTop: $('#mapContacts').offset().top}, 700);
}
});
map.geoObjects.add(myCollection);
map.setBounds(myCollection.getBounds(), {checkZoomRange: true});
});
}
});
以上是关于javascript Yandex映射Api的主要内容,如果未能解决你的问题,请参考以下文章
在构造函数中移动 yandex 映射控制器
如何获取 Yandex 全景图像
python [yandex api] yandex api
Yandex.Direct - Python 中的 API
如何使用 Yandex Disk c# Api
API 密钥无效 Yandex Translate