ionographic 프레임 워크에 Google지도를 추가하고 내 위치 정보에 액세스 할 수 있습니다. Google지도에서 다른 위치를 추가하고 싶습니다. 몇 가지 지침을 제공하십시오.Angularjs를 사용하여 Google지도에서 원하는 위치를 설정하고 싶습니다.
이것은
.controller ('MapCtrl'기능 ($ 범위, $ ionicLoading, $ 컴파일) {
$scope.init = function() {
var myLatlng = new google.maps.LatLng(43.07493,-89.381388);
var mapOptions = {
center: myLatlng,
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"),
mapOptions);
var contentString = "<div><a ng-click='clickTest()'>Click me!</a></div>";
var compiled = $compile(contentString)($scope);
var infowindow = new google.maps.InfoWindow({
content: compiled[0]
});
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Uluru (Ayers Rock)'
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
$scope.map = map;
};
// google.maps.event.addDomListener(window, 'load', initialize);
$scope.centerOnMe = function() {
if(!$scope.map) {
return;
}
$scope.loading = $ionicLoading.show({
content: 'Getting current location...',
showBackdrop: false
});
navigator.geolocation.getCurrentPosition(function(pos) {
$scope.map.setCenter(new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude));
var p1 =new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude);
console.log(p1);
$ionicLoading.hide();
}, function(error) {
alert('Unable to get location: ' + error.message);
});
};
$scope.clickTest = function() {
alert('Example of infowindow with ng-click')
};
})
내 제어기이고;
누구는 나에게 –
도와주세요 시도? –
나는지도의 중심을 얻을 것이다. 그러나 나는 그 위치에서 위도와 경도를 얻고 자한다. @ shammon –