Add Event in Custom infobox bing map in angular/ts

Saravanan Vajjiravelu (C) 1 Reputation point
2022-06-30T12:06:36.787+00:00

Due to requirement i have created the custom infobox and able to displayed when pushpin is clicked. But I need to add event in custom infobox. I have added the button and other controls but the click event/events are not working/fired . below is sample source code

infoboxTemplate = '<div><div class="title">{title}</div><button (click)="btnclick()" type="button">test</button></div>';

var pin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(this.locLat, this.locLong), {
icon: this.iconUrl,
anchor: new Microsoft.Maps.Point(25, 25), text: this.icount.toString()
});
pin.metadata = {
title: this.PCPname,
description: this.PCPname,
PCPaddr: this.PCPname,
htmldiv: this.infoboxTemplate
};
this.infobox = new Microsoft.Maps.Infobox(
this.map.getCenter(),
{ htmlContent: this.infoboxTemplate, visible: false }
);
this.infobox.setMap(this.map);

      Microsoft.Maps.Events.addHandler(pin, 'click', this.pushpinClicked.bind(this));  

      this.map.entities.push(pin);
Windows Maps
Windows Maps
A Microsoft app that provides voice navigation and turn-by-turn driving, transit, and walking directions.
257 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Clemens Schotte 356 Reputation points Microsoft Employee
    2022-07-04T10:24:58.713+00:00

    The infoboxTemplate variable is a html string and is not parsed by angular. You need to add valid html, see this working sample https://samples.bingmapsportal.com/?sample=infobox-events

    1 person found this answer helpful.
    0 comments No comments

  2. Saravanan Vajjiravelu (C) 1 Reputation point
    2022-07-05T10:54:50.803+00:00

    Hi @Clemens Schotte ,

    Thanks for looking into it.

    The sample which is provided is Default info box which has limited options.

    Based on attached requirement I need to design a custom Infobox and there events are not trigger in Angular Type script. Pagination/Button click events are not triggered inside bing map.

    217669-capture.png


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.