geolocation.getCurrentPosition not working in ANDROID device, but when using in browser it’s working fine
What else i have to do…
This is my controller
.controller(‘MapController’, function($scope, $ionicLoading,$http,$ionicPopup) {
google.maps.event.addDomListener(window, 'load', function() {
var myLatlng = new google.maps.LatLng(37.3000, -120.4833);
var mapOptions = {
center: myLatlng,
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
navigator.geolocation.getCurrentPosition(function(pos) {
map.setCenter(new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude));
var myLocation = new google.maps.Marker({
position: new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude),
map: map,
title: "My Location"
});
var lat_long = pos.coords.latitude+","+pos.coords.longitude;
var link = "https://api.forecast.io/forecast/[MY API KEY]/"+lat_long;
$http.get(link, {}).then(function (res){
//console.log(res.data.currently.temperature);
var farenheit_temp = res.data.currently.temperature;
var celcius_temp = (farenheit_temp - 30) / 2;
var alertPopup = $ionicPopup.alert({
title: 'Details',
template: "<p>Temperature:- "+celcius_temp.toFixed(2)+" c<br/>"+res.data.currently.summary+"<br/>Humidity:- "+res.data.currently.humidity+"<br>Wind Speed:- "+res.data.currently.windSpeed+"</p>",
});
});
},function(){},{maximumAge:60000, timeout:2000, enableHighAccuracy:true});
$scope.map = map;
});
})