Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have Google Maps fully working in a custom visual except for the filtering of the rest of the report when I select a marker in the map.
My question is; how can I store the
identity: powerbi.visuals.ISelectionId
in the marker properties such that I can use
this.selectionManager.select(marker.identity, true)
to filter the report on e.g. a click event on the map?
I currently have:
var markers = this.viewModel.dataPoints.map(function (dp, i) { return new google.maps.Marker({ position: new google.maps.LatLng( dp.lat, dp.lng ), title: dp.category, zIndex: i }) })
Thanks for any help or suggestions!
Martijn
Solved! Go to Solution.
I solved it the easy way by creating the click event on creation of the marker:
var markers = this.viewModel.dataPoints.map(function (dp, i) { var marker = new google.maps.Marker({ position: new google.maps.LatLng( dp.lat, dp.lng ), title: dp.category, zIndex: i }) google.maps.event.addListener(marker, 'click', (function (marker) { return function () { thisRef.selectionManager.select(dp.identity) } })(marker)); return marker; })
I solved it the easy way by creating the click event on creation of the marker:
var markers = this.viewModel.dataPoints.map(function (dp, i) { var marker = new google.maps.Marker({ position: new google.maps.LatLng( dp.lat, dp.lng ), title: dp.category, zIndex: i }) google.maps.event.addListener(marker, 'click', (function (marker) { return function () { thisRef.selectionManager.select(dp.identity) } })(marker)); return marker; })
I noticed that it is possible to add custom properties to a Marker, but that typescript forces you to use .set and .get.
Updated code:
var markers = this.viewModel.dataPoints.map(function (dp, i) { var marker = new google.maps.Marker({ position: new google.maps.LatLng( dp.lat, dp.lng ), title: dp.category, zIndex: i }); marker.set('identity',dp.identity); google.maps.event.addListener(marker, 'click', (function (marker) { return function () { thisRef.selectionManager.select(marker.get('identity')); } })(marker)); return marker; });
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
8 | |
7 | |
2 | |
2 | |
2 |
User | Count |
---|---|
6 | |
5 | |
4 | |
4 | |
4 |