This project is read-only.

InfoWindow is shown before the second click

Dec 6, 2009 at 12:51 AM

Hi. I am dynamically adding Markers to the map. and handle the events. But I have a problem with that. here is my code


   protected void Page_Load(object sender, EventArgs e)
                GoogleMap1 = new GoogleMap();
                GoogleMap1.Width = new Unit(800);
                GoogleMap1.Height = new Unit(600);
                GoogleMap1.Key = Key;
                GoogleMap1.Markers.Add(new GoogleMarker("istanbul"));
                GoogleMap1.MarkerEvents.Click += new EventHandler<GoogleLocationEventArgs>(MarkerEvents_Click);   
                GoogleMap1.Address = "istanbul";


        void MarkerEvents_Click(object sender, Artem.Web.UI.Controls.GoogleLocationEventArgs e)
            GoogleMarker gm = sender as GoogleMarker;
            GoogleMap1.MarkerEvents.Click -= new EventHandler<GoogleLocationEventArgs>(MarkerEvents_Click);

My problem is, when I first click the marker, an empty info window is shown. But after the second click, I get what I want.
What can I do for that ?

Dec 6, 2009 at 6:06 PM


Try adding the InfoWindowContent control  in Page_Load, as well.
It is shown after the first click, because you actually add it when click occurs.
So, before first click to occur, the info window content is missing and that why it is empty.


Dec 7, 2009 at 4:39 PM
Edited Dec 7, 2009 at 4:40 PM


I have tested your case with dynamically added markers and adding UserControl to their InfoContent.
Obviously at present version the InfoContent of markers is not persisted by GoogleMap control.
So, you have to add that UserControl every time you need it.

What I did is adding the InfoContent every time OnPreRender instead just when map double clicked.
Here bellow is the code of my test.

Page markup:

<artem:GoogleMap ID="GoogleMap1" runat="server" Latitude="42.1229" Longitude="24.7879"
    EnableScrollWheelZoom="true" OnDoubleClick="HandleMapDoubleClick">
<asp:Button ID="btnPost" runat="server" Text="Post" />


public partial class marker_InfoContent : System.Web.UI.Page {

    #region Methods ///////////////////////////////////////////////////////////////////////////

    protected void HandleMapDoubleClick(object sender, GoogleLocationEventArgs e) {

        GoogleMarker marker = new GoogleMarker(e.Location.Latitude, e.Location.Longitude);

    protected override void OnPreRender(EventArgs e) {

        foreach (GoogleMarker marker in GoogleMap1.Markers) {
Hope this helps.
Dec 12, 2009 at 3:07 PM

Hi velio;

I still have the same problem, then I started to search it again. I found

<div id="GoogleMap1asdasd_Templates" style="display: none;">
<div id="Marker0Content">
my data

I think this is the div that the marker has to show when it is clicked. So I believe the problem is in the second or further clicks, script cannot find that div "

So where can be the problem?