diff --git a/public/js/main.js b/public/js/main.js index 362d7ae..334c23a 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -105,15 +105,43 @@ function searchAdderess() function showMeOnTheMap() { - myMap.geoObjects.add( - new ymaps.Placemark( - [ymaps.geolocation.latitude, ymaps.geolocation.longitude], - { - balloonContentHeader: ymaps.geolocation.country, - balloonContent: ymaps.geolocation.city, - balloonContentFooter: ymaps.geolocation.region - }, - {iconImageHref: '/ico/man.png', iconImageSize: [32, 37]} - ) -); + var userLat = 0; + var userLng = 0; + navigator.geolocation.getCurrentPosition(function(pos) { + userLat = pos.coords.latitude; + userLng = pos.coords.longitude; + + myMap.geoObjects.add( + new ymaps.Placemark( + [userLat, userLng], + { + balloonContentHeader: ymaps.geolocation.country, + balloonContent: ymaps.geolocation.city, + balloonContentFooter: ymaps.geolocation.region + }, + { + iconImageHref: '/ico/man.png', + iconImageSize: [32, 37] + } + ) + ); + }, function(){ + userLat = ymaps.geolocation.latitude; + userLng = ymaps.geolocation.longitude; + + myMap.geoObjects.add( + new ymaps.Placemark( + [userLat, userLng], + { + balloonContentHeader: ymaps.geolocation.country, + balloonContent: ymaps.geolocation.city, + balloonContentFooter: ymaps.geolocation.region + }, + { + iconImageHref: '/ico/man.png', + iconImageSize: [32, 37] + } + ) + ); + }); }