Click here to Skip to main content
15,899,475 members

Comments by Janardhanam Julapalli (Top 167 by date)

Janardhanam Julapalli 11-Apr-19 6:14am View    
sure. I will do that.
Janardhanam Julapalli 11-Apr-19 5:14am View    
Its working in chrome. Thank You so much.
Janardhanam Julapalli 11-Apr-19 5:05am View    
I have given permission. Also nothing in console apart from the log messages I gave. Browser related problem? Using safari now.
Janardhanam Julapalli 11-Apr-19 3:47am View    
if (navigator.geolocation) {
console.log('in');//this is printing
navigator.geolocation.getCurrentPosition(function(position) {
console.log('in in');//this is not printing

This is the actual problem. Earlier I read that getCurrentPosition() will not work with http. Now I have https but still not working.
Janardhanam Julapalli 11-Apr-19 3:42am View    
I have tried something like you have mentioned above. Now I have used the code which you have given.

function getCurrentLatLang(){
var map, infoWindow;

infoWindow = new google.maps.InfoWindow;

// Try HTML5 geolocation.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {

var Lat = position.coords.latitude;
var Long = position.coords.longitude;
getGeoLocation(Lat,Long)

}, function() {
console.log('error');//this line being executed
});
} else {

// Browser doesn't support Geolocation

}
}

function getGeoLocation(latitude,longitude){
var map;
// var latitude = 13.0547712;
// var longitude = 80.2578432;
var myLatlng = new google.maps.LatLng(latitude,longitude);
var myOptions = {
zoom: 17,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.SATELLITE
};


map = new google.maps.Map(document.getElementById('map_div'),
myOptions);

// marker STARTS
var marker = new google.maps.Marker({
position: myLatlng,
title:"Click to view info!"
});
marker.setMap(map);
// marker ENDS
google.maps.event.addListener(map, "click", function (e) {

//lat and lng is available in e object
var latLng = e.latLng;
var lat = e.latLng.lat();
var lang = e.latLng.lng();
$('#latitude').val(lat);
$('#longitude').val(lang);
});
// google.maps.event.addDomListener(window, 'load', initialize);
}