public/js/maps-create.js
// if geolocation is supported and can access current position
if geolocation is supported and can access current position
if geolocation is supported and can access current position
function success(position) {
            currentPosition = {
                lat: position.coords.latitude,
                lng: position.coords.longitude,
            }
            latlng = new google.maps.LatLng(currentPosition);
            function setLatLng(lat, lng) {
                document.getElementById("lat").setAttribute('value', lat);
                document.getElementById("lng").setAttribute('value', lng);
            }
             in DOM
            setLatLng(currentPosition.lat, currentPosition.lng);
            var myOptions = {
                zoom: 18,
                center: latlng,
                streetViewControl: false,
                mapTypeControl: false,
            }
            map = new google.maps.Map(document.getElementById("map"), myOptions);
            marker = new google.maps.Marker({
                map: map,
                draggable: true,
                position: latlng,
                icon: '../../imgs/maps-icons/marker-test-large-vert.png',
            });
            google.maps.event.addListener(marker, 'dragend', function () {
                var point = marker.getPosition()
                var lat = marker.getPosition().lat();
                var lng = marker.getPosition().lng();
                document.getElementById("lat").setAttribute('value', lat);
                document.getElementById("lng").setAttribute('value', lng);
                map.panTo(point);
            });
            status.textContent = 'Location found!'; 
        }
function success ( position ) { currentPosition = { lat : position . coords . latitude , lng : position . coords . longitude , } latlng = new google . maps . LatLng ( currentPosition ) ; function setLatLng ( lat , lng ) { document . getElementById ( "lat" ) . setAttribute ( 'value' , lat ) ; document . getElementById ( "lng" ) . setAttribute ( 'value' , lng ) ; } setLatLng ( currentPosition . lat , currentPosition . lng ) ; var myOptions = { zoom : 18 , center : latlng , streetViewControl : false , mapTypeControl : false , } map = new google . maps . Map ( document . getElementById ( "map" ) , myOptions ) ; marker = new google . maps . Marker ( { map : map , draggable : true , position : latlng , icon : '../../imgs/maps-icons/marker-test-large-vert.png' , } ) ; google . maps . event . addListener ( marker , 'dragend' , function ( ) { var point = marker . getPosition ( ) var lat = marker . getPosition ( ) . lat ( ) ; var lng = marker . getPosition ( ) . lng ( ) ; document . getElementById ( "lat" ) . setAttribute ( 'value' , lat ) ; document . getElementById ( "lng" ) . setAttribute ( 'value' , lng ) ; map . panTo ( point ) ; } ) ; status . textContent = 'Location found!' ; }
if geolocation is supported and can access current position
if geolocation is supported and can access current position
// current location of the user // Set static latitude, longitude value // render initial lat/lng value from currentlocation // render initial lat/lng value from currentlocation in DOM // Set map options // Create map object with options // Create and set the marker // save marker current position in individual variables // Register Custom "dragend" Event // Get the Current position, where the pointer was dropped // render value of dragged lat in DOM // render value of dragged lng in DOM // Center the map at given point