Open google-map info-window with ng-map without alias in ng-controller

0

I'm using this library (ng-map) / github .

You are giving template rejection error in my controller, how could I solve this?

  

Error shown: Possibly unhandled rejection: info-window working as a template must have a container

Controller method:

 $scope.renderMap = function(content) {
            /*****
             * Documentação:
             * https://ngmap.github.io/
             */
            $scope.dataMap = content;
            $scope.typesFilter = "['address']";

            NgMap.getMap().then(function(map) {
                $scope.map = map;
            });


            $scope.template_modal = {
                cached_customers:'cached_customers.html',
                cached_private_schools:'cached_private_schools.html'
            };

            $scope.showModal = function(evt, storeId) {
                var idx = $filter('FilterData')(storeId,$scope.dataMap.collection, 'id');
                if (idx != null) {
                    $scope.store = $scope.dataMap.collection[idx];
                    $scope.map.showInfoWindow($scope.store.infoWindow, this);
                }
            };


        };

Briefly, from down to down it gets the API result:

var private_schools = rtn.results.location_schools.private_schools;
if (private_schools.length > 0) {
    for (var i in private_schools) {
        collection.push({
            id: private_schools[i].id,
            name: private_schools[i].name,
            lat: private_schools[i].latitude,
            lon: private_schools[i].longitude,
            infoWindow: 'cached_private_schools',
            type: 'private_schools',
            index: j,
            image: {
                url: '/webapp/sistema/img/pin_school.png',
                size: [30, 32],
                origin: [0, 0],
                anchor: [0, 32]
            }
        });
        j++;
    }
}

var dadosMapa = {
shape: {
    coords: [1, 18, 20, 23, 46, 20, 18, 1],
    type: 'poly'
},
collection: collection,
center:$scope.centerMap,
zoom:zoom
}

$scope.renderMap(dadosMapa);

A view:

<div ng-controller="MyController">
    <div map-lazy-load="https://maps.google.com/maps/api/js"
         map-lazy-load-params="{{googleMapsUrl}}" ng-init="loadedMap = true">
        <ng-map class="size-map" zoom="{{dataMap.zoom}}" center="{{dataMap.center}}">

            <info-window id="cached_customers" template="{{template_modal.cached_customers}}"></info-window>
            <info-window id="cached_private_schools" template="{{template_modal.cached_private_schools}}"></info-window>

            <marker id="modal_{{item.id}}" ng-repeat="item in dataMap.collection"
                    icon="{{item.image}}"
                    shape="{{dataMap.shape}}"
                    title="{{item.name}}"
                    position="{{item.lat}}, {{item.lon}}"
                    z-index="{{item.index}}"
                    on-click="showModal(event, item.id)"
            >
            </marker>

        </ng-map>
    </div>
    <script type="text/ng-template" id="cached_customers.html">
        <div ng-non-bindable="">
            Dados<br/>
            Lat: {{anchor.getPosition().lat()}}<br/>
            Lng: {{anchor.getPosition().lng()}}<br>
            ID: {{store.id}}<br>
            Nome: {{store.name}}<br>
        </div>
    </script>
    <script type="text/ng-template" id="cached_private_schools.html">
        <div ng-non-bindable="">
            Dados<br/>
            Lat: {{anchor.getPosition().lat()}}<br/>
            Lng: {{anchor.getPosition().lng()}}<br>
            ID: {{store.id}}<br>
            Nome: {{store.name}}<br>
        </div>
    </script>
</div>

Here below it works, where am I going wrong?

link

    
asked by anonymous 28.03.2018 / 16:11

1 answer

0

I solved without using a template and it worked:

<div ng-controller="MyController">
    <div map-lazy-load="https://maps.google.com/maps/api/js"
         map-lazy-load-params="{{googleMapsUrl}}" ng-init="loadedMap = true">
        <ng-map class="size-map" zoom="{{dataMap.zoom}}" center="{{dataMap.center}}">

<info-window id="cached_customers">
    <div ng-non-bindable="">
    Dados<br/>
    Lat: {{anchor.getPosition().lat()}}<br/>
    Lng: {{anchor.getPosition().lng()}}<br>
    ID: {{store.id}}<br>
    Nome: {{store.name}}<br>
    </div>
</info-window>
<info-window id="cached_private_schools">
    <div ng-non-bindable="">
    Dados<br/>
    Lat: {{anchor.getPosition().lat()}}<br/>
    Lng: {{anchor.getPosition().lng()}}<br>
    id: {{store.id}}<br>
    Nome: {{store.name}}<br>
   </div>
</info-window>

...

    
29.03.2018 / 15:08