-1

I have a AngularJS application that displays a ngmap, however, i want to use this library to mark the current location of user.

I already have downloaded the library using bower. My question is, how do I use it with ngmap?

Sorry for bad English. Thank you.

1 Answers1

1

To get the current users location, you need to check if their browser supports geolocation...

if(navigator.geolocation){
    navigator.geolocation.getCurrentPosition(function(position){
        var latitude = position.coords.latitude;
        var longitude = position.coords.longitude;

if thats true then we make a map variable with the geolocation:

var geolocalpoint = new google.maps.LatLng(latitude, longitude);
        map.setCenter(geolocalpoint);

        var mapOptions = {
            zoom: 8,
            center: geolocalpoint,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        }

then we make the marker

//Place a marker
        var geolocation = new google.maps.Marker({
            position: geolocalpoint,
            map: map,
            title: 'Your geolocation',
            icon: 'http://labs.google.com/ridefinder/images/mm_20_green.png'
        });
    });
}

the part where it says

map.setCenter(geolocalpoint);

that centers the map around the persons geolocation, if you dont want that just remove it:) Hope i helped

gone
  • 56
  • 9