The first time I use AngularJS with the Google Maps API, the point is to use a .directive to show the google map.
app.directive("myMaps",function(){
return{
restrict:'E',
template:'<div></div>',
replace:true,
scope: {
lat: '=',
long: '='
},
link: function(scope, element, attrs) {
var myLatLng = new google.maps.LatLng(scope.lat,scope.long);
var mapOptions = {
center: myLatLng,
zoom: 16,
mapTypeId: google.maps.MapTypeId.SATELLITE
};
var map = new google.maps.Map(document.getElementById(attrs.id),
mapOptions);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title:"Posicion"
});
marker.setMap(map);
}
};
});
The problem is the following, I am using a table that shows several centers in a datatable, and with a "location" button to show a modal that shows the location of the center thanks to the coordinates that are requested and sends the respective function of the controller So I'm using the directive and take the latitude and longitude of the center.
<div class="modal-body">
<p>{{ centro.razon }}</p> <br>
<p>{{ centro.latitud }}, {{ centro.longitud }}</p>
<my-maps id="map-canvas" lat= "centro.latitud" long= "centro.longitud"></my-maps></div>
Unfortunately, I can not show when I send the coordinates in that way, it only appears when I put default coordinates.
I would like to know in which part I am confused, since that directive works if, for example, I type lat = -5.53268 long = -78.43484, the normal table shows the map. But with what I send I get this gray: /