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
Related Q & A:
- How can I trick SSH to connect using different configurations based on current location?Best solution by Server Fault
- How can I display older custom post outside the loop in Wordpress?Best solution by Quora
- How to get user's current location?Best solution by Stack Overflow
- How can I display data in a listview?Best solution by Stack Overflow
- How can I calculate my current CTC?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.