Why does google now have an auto-detect location?

Hi, how can we Display the Current Location using google maps.?

  • hi, how can we Display the Current Location using google maps.? I tried below code ...:but i am getting Client Key Null... if(null != google.loader.ClientLocation) { var lat = google.loader.ClientLocation.latitude; var lan = google.loader.ClientLocation.longitude; center = new GLatLng(lat, lon); alert("Client Location Not null..."); } else{ }

  • Answer:

    You can use the given code to detect the current location. function showMap(position) { golballocation = new google.maps.LatLng(position.coords.latit… position.coords.longitude); var centerloc = new google.maps.LatLng(position.coords.latit… position.coords.longitude); var myOptions = { zoom: 7, center: centerloc, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById(… myOptions); var polyOptions = { strokeColor: '#000000', strokeOpacity: 1.0, strokeWeight: 3 }; poly = new google.maps.Polyline(polyOptions); poly.setMap(map); // Add a listener for the click event google.maps.event.addListener(map, 'click', addLatLng); var s = document.querySelector('#status'); s.innerHTML = typeof msg == 'string' ? msg : "Success"; map.setCenter(golballocation); addFirst() } /** * Handles click events on a map, and adds a new point to the Polyline. * @param {MouseEvent} mouseEvent */ function addFirst() { // Add a new marker at the new plotted point on the polyline. var marker = new google.maps.Marker({ position: golballocation, title: '#', map: map }); var contentString = 'Here we need to put html which will be displayed within balloon, in this case an iframe which will have a form to get some input from user'; var infowindow = new google.maps.InfoWindow({ content: contentString }); infowindow.open(map, marker); } function addLatLng(event) { // Add a new marker at the new plotted point on the polyline. var marker = new google.maps.Marker({ position: event.latLng, title: 'Add New Info', map: map }); var contentString = 'Here we need to put html which will be displayed within balloon, in this case an iframe which will have a form to get some input from user'; var infowindow = new google.maps.InfoWindow({ content: contentString }); infowindow.open(map, marker); }

chandra sekhar at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.