Я на карте v2 - теперь с GPS

This commit is contained in:
Krivchikov Dmitry 2014-04-09 12:56:10 +04:00
parent 7fdf4f446d
commit 524da1831a
1 changed files with 39 additions and 11 deletions

View File

@ -105,15 +105,43 @@ function searchAdderess()
function showMeOnTheMap() function showMeOnTheMap()
{ {
myMap.geoObjects.add( var userLat = 0;
new ymaps.Placemark( var userLng = 0;
[ymaps.geolocation.latitude, ymaps.geolocation.longitude], navigator.geolocation.getCurrentPosition(function(pos) {
{ userLat = pos.coords.latitude;
balloonContentHeader: ymaps.geolocation.country, userLng = pos.coords.longitude;
balloonContent: ymaps.geolocation.city,
balloonContentFooter: ymaps.geolocation.region myMap.geoObjects.add(
}, new ymaps.Placemark(
{iconImageHref: '/ico/man.png', iconImageSize: [32, 37]} [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]
}
)
);
});
} }