From 524da1831ae7542df4efc16bf29d5d2baa928a7a Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Wed, 9 Apr 2014 12:56:10 +0400 Subject: [PATCH] =?UTF-8?q?=D0=AF=20=D0=BD=D0=B0=20=D0=BA=D0=B0=D1=80?= =?UTF-8?q?=D1=82=D0=B5=20v2=20-=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20?= =?UTF-8?q?=D1=81=20GPS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/main.js | 50 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 11 deletions(-) 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] + } + ) + ); + }); }