From f65d1b5afeb03b55fdfaf60271685e2da56df9e2 Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Mon, 14 Apr 2014 11:26:49 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=BC=D0=BD=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D1=80=D0=B0=D1=81=D1=88=D0=B8=D1=80=D0=B8=D0=BB=20=D0=B2=D0=BE?= =?UTF-8?q?=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE=D1=81=D1=82=D1=8C=20=D0=BA?= =?UTF-8?q?=D0=BD=D0=BE=D0=BF=D0=BA=D0=B8=20'=D0=AF=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=80=D1=82=D0=B5'.=20=D0=A2=D0=B5=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D1=8C=20=D0=BF=D1=80=D0=B8=20=D0=B7=D0=B0=D0=B3=D1=80?= =?UTF-8?q?=D1=83=D0=B7=D0=BA=D0=B5=20=D0=BA=D0=B0=D1=80=D1=82=D0=B0=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=BB=D0=B6=D0=BD=D0=B0=20=D1=86=D0=B5=D0=BD=D1=82?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=D1=81=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=20=D1=80=D0=B0=D1=81=D0=BF=D0=BE=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8E=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D1=8F.=20=D0=9F=D1=80=D0=B8=20=D1=83=D1=82?= =?UTF-8?q?=D0=BE=D1=87=D0=BD=D0=B5=D0=BD=D0=B8=D0=B8=20=D0=BA=D0=BE=D0=BE?= =?UTF-8?q?=D1=80=D0=B4=D0=B8=D0=BD=D0=B0=D1=82=20=D0=BA=D0=B0=D1=80=D1=82?= =?UTF-8?q?=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D1=89=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=D1=81=D1=8F=20=D0=B2=D1=81=D0=BB=D0=B5=D0=B4=20=D0=B7?= =?UTF-8?q?=D0=B0=20=D1=82=D0=BE=D1=87=D0=BA=D0=BE=D0=B9=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/main.js | 58 +++++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/public/js/main.js b/public/js/main.js index b79b538..f1f210e 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -6,10 +6,11 @@ ymaps.ready(init); var myMap; var categories; var points = Array(); +var im; function init() { myMap = new ymaps.Map("map", { - center: [59.9, 30.3], + center: [ymaps.geolocation.latitude, ymaps.geolocation.longitude], zoom: 9, behaviors: ['default', 'scrollZoom'] }); @@ -36,6 +37,19 @@ function init() { myMap.balloon.close(); } }); + + im = new ymaps.Placemark( + [ymaps.geolocation.latitude, ymaps.geolocation.longitude], + { + balloonContentHeader: 'Вы здесь', + balloonContent: '' + }, + { + iconImageHref: '/ico/man.png', + iconImageSize: [32, 37] + } + ); + myMap.geoObjects.add(im); } function getPoints() @@ -112,47 +126,11 @@ function searchAdderess() function showMeOnTheMap() { - 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] - } - ) - ); - myMap.setCenter([userLat, userLng]); - }, 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] - } - ) - ); - myMap.setCenter([userLat, userLng]); + im.geometry.setCoordinates([pos.coords.latitude, pos.coords.longitude]); }); + + myMap.setCenter(im.geometry.getCoordinates()); } function activateAddPoint()