Matt6607699
Posts: 0
Joined: Sat Jan 25, 2014 7:18 am

How to access a Map marker by it's id key(or otherwise) in ionic.

HI, I am populating a map with Markers from database location info. I assign the db _id to the "id key" property of the marker. I also ng-repeat cards at the same time as creating the markers(same db call) so that the $index value of the card and it's corresponding map marker are the same. I would like to click on the card and have the map center to the corresponding marker and open it's info-window. How can I target a specific map marker after an ng-click event? Do I create a new function for the click event and use the $scope.mapControl.getGMarkers() somehow? And then Trigger a click on that marker? Thank you for any guidance on this topic.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How to access a Map marker by it's id key(or otherwise) in ionic.

Hello Matt,

You can set the marker as a parameter of the ng-click function

Matt6607699
Posts: 0
Joined: Sat Jan 25, 2014 7:18 am

How to access a Map marker by it's id key(or otherwise) in ionic.

Ok I think that I'm getting closer.

Right now I have a list of cards(below the map) and markers on a map both being displayed from the same database service.

When I click on a card, I use ng-click : displayWindow($index)

in the displayWindow(index) function:
code
var mark = $scope.dbMarkers[index];
console.log("Selected Marker = "+JSON.stringify(mark));

var coords = {
latitude: mark.latitude,
longitude: mark.longitude
};

$scope.singleWindow = {
title: " ",
coords: coords,
show: true
};
/code

This opens all of the Windows for every marker on my map even though I am using the single Window directive. Also, even when clicking the map markers, it allows multiple windows to be open. How do I get it to just display one window?
Image Image Image

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How to access a Map marker by it's id key(or otherwise) in ionic.

Please look at this google maps documentation page how to close infowindow: https://developers.google.com/maps/do...

Return to “Issues”