I am trying to create a link inside InfoWindow on a Google map using the angular -google-maps ui-gmap-windows module.
In my HTML template, I have:
<ui-gmap-google-map center='main.map.center' zoom='main.map.zoom' options='main.map.options'> <ui-gmap-markers models="main.markers" coords="'self'" icon="'icon'" options="'options'" click="'onClick'" fit="true"> <ui-gmap-windows show="'showWindow'" closeClick="'closeClick'" ng-cloak> <div class="mapinfowindow" data-ui-sref="display({id: id})"> <span class="itemname" data-ng-non-bindable>{{ title }}</span> </div> </ui-gmap-windows> </ui-gmap-markers> </ui-gmap-google-map>
In my controller, I have:
uiGmapGoogleMapApi.then(function(maps) { vm.itemlist = search.getItemList(); var markers = []; _.each(vm.itemlist,function(item){ search.getGeometry(item.href).then(function(marker) { marker.title = item.en; marker.id = item.href; marker.showWindow = false; marker.options = { title: item.en, icon: markericon.normal }; marker.onClick = function() { vm.markerClick(marker); }; marker.closeClick = function() { vm.markerCloseClick(marker); }; markers.push(marker); }); }); vm.markers = markers; });
Please note that I use the syntax "controller as", so vm.markers in the controller appears as main.markers in the html template.
The problem I see is that the data-ui-sref="display({id: id})" in html changes state to the "display" page, but does not execute through id as the value of $ stateParams, which is clearly not good since I will not know what to show.
I have one more link to the same page created outside of InfoWindow (in the list of results), and I click on the id value:
<div data-ng-repeat="entry in main.itemlist"> <div data-ui-sref="display({id: entry.id})">
Any help in getting InfoWindow's working information would be greatly appreciated.
javascript angularjs google-maps angular-ui-router angular-google-maps
egeland
source share