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{
}Hi, how can we Display the Current Location using google maps.?
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);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment