//1)
ymaps.ready(function () {
var map;
ymaps.geolocation.get().then(function (res) {
var mapContainer = $('#map'),
bounds = res.geoObjects.get(0).properties.get('boundedBy'),
// Рассчитываем видимую область для текущей положения пользователя.
mapState = ymaps.util.bounds.getCenterAndZoom(
bounds,
[mapContainer.width(), mapContainer.height()]
);
createMap(mapState);
});
function createMap (state) {
map = new ymaps.Map('map', state);
}
});Код определяет местоположение (не через ip)
как правильно задать расположение меток(маркеров)
2)
и как передать при инициализации карты, такой:
ymaps.ready(init);
var myMap;
function init(){
myMap = new ymaps.Map("map", {
center: [55, 60],
zoom: 12,
controls: ['zoomControl', 'fullscreenControl']
});
}в параметр center координаты через переменные от:
navigator.geolocation.getCurrentPosition(
function (position) {
var userlong = position.coords.longitude;// переменная 1
var userlat = position.coords.latitude;// переменная 2
});на мой взгляд (2) легче воспринимается, чем в 1м примере