Я на карте 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()
{ {
var userLat = 0;
var userLng = 0;
navigator.geolocation.getCurrentPosition(function(pos) {
userLat = pos.coords.latitude;
userLng = pos.coords.longitude;
myMap.geoObjects.add( myMap.geoObjects.add(
new ymaps.Placemark( new ymaps.Placemark(
[ymaps.geolocation.latitude, ymaps.geolocation.longitude], [userLat, userLng],
{ {
balloonContentHeader: ymaps.geolocation.country, balloonContentHeader: ymaps.geolocation.country,
balloonContent: ymaps.geolocation.city, balloonContent: ymaps.geolocation.city,
balloonContentFooter: ymaps.geolocation.region balloonContentFooter: ymaps.geolocation.region
}, },
{iconImageHref: '/ico/man.png', iconImageSize: [32, 37]} {
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]
}
)
);
});
} }