Hi, i’m trying to make an Android app that shows map with a marker, when you click that mark it’ll show a popup with some data about the address and a click button to send you to Google Maps app with the coordinates using the launchnavigator cordova plugin.
So far this is what i got:
- It loads the map.
- Show the marker.
- Open the popup with a “click me” text.
- It open the map, but i get a “null, null” on coordinates.
Here is my code:
` .controller(‘HomeCtrl’, function($scope, $ionicLoading, $compile) {
function initialize() {
//loading spiner
$ionicLoading.show({
template: '<ion-spinner icon="bubbles"></ion-spinner><br/>Acquiring location!'
});
//false coordinates:
var myLatlng = new google.maps.LatLng(43.07493,-89.381388);
//get Lat and Long separatedly to use latter
$scope.lat = myLatlng.lat();
$scope.long = myLatlng.lng();
//map options
var mapOptions = {
center: myLatlng,
zoom: 16,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"),
mapOptions);
//Marker + infowindow + angularjs compiled ng-click
var contentString = "<div><a ng-click='clickTest()'>Abrir o mapa!</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;
$ionicLoading.hide();
}
google.maps.event.addDomListener(window, 'load', initialize);
$scope.clickTest = function(lat, long) {
launchnavigator.navigate([lat, long]);
};
})`
So how can i get the lat and long separatedly and send it to launchnavigator so i can use it on a map?
Thanks everyone