InfoWindow is not displayed - Add marker from JS

Jul 29, 2008 at 4:14 PM
Edited Jul 30, 2008 at 11:22 AM
StringBuilder buff = new StringBuilder();

buff.AppendFormat("{0}.Markers = null;{0}.clearOverlays();", GoogleMap1.ClientMapID);
buff.AppendFormat("{0}.addMarker(", GoogleMap1.ClientMapID)
      .Append("{")
      .AppendFormat("Latitude:{0},Longitude:{1},Text:'Marker 1'",
                                    JsUtil.Encode(56.591565), JsUtil.Encode(84.912045))
      .Append("});");
buff.AppendFormat("{0}.render();", GoogleMap1.ClientMapID);

System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, GetType(), "__Test",
           "Sys.Application.add_load(function() {" + buff.ToString() + ";});", true);

The field "Text" does not work. The InfoWindow is not displayed :-(((
Aug 1, 2008 at 2:13 PM
Edited Aug 1, 2008 at 6:11 PM
Has already understood.
Here a working variant.

StringBuilder buff = new StringBuilder();

buff.AppendFormat("{0}.Markers = null;{0}.clearOverlays();", GoogleMap1.ClientMapID);
buff.AppendFormat("{0}.addMarker(", GoogleMap1.ClientMapID)
      .Append("{")
      .AppendFormat("Latitude:{0},Longitude:{1},Text:'Marker 1',OpenInfoBehaviour:Artem.Web.OpenInfoBehaviour.Click",
                                    JsUtil.Encode(56.591565), JsUtil.Encode(84.912045))
      .Append("});");
buff.AppendFormat("{0}.render();", GoogleMap1.ClientMapID);

System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, GetType(), "__Test",
           "Sys.Application.add_load(function() {" + buff.ToString() + ";});", true);

To whom it is interesting, it was picked in:
GoogleMaps Control 3.4 Solution (Library & Sample Website) \Artem.GoogleMap\Scripts\GoogleMap3.debug.js
Aug 12, 2008 at 6:39 PM

Hi and how it shoul be if i wan to display a custom Marker (IconSize, IconAnchor, ImageUrl)?

protected override void OnPreRender(System.EventArgs e)
{
    base.OnPreRender(e);
    if (this.IsPostBack) { 
        Artem.Web.UI.Controls.GoogleSize size = new GoogleSize(24, 24);
        Artem.Web.UI.Controls.GooglePoint anchor = new GooglePoint(10, 10);
        string imgUrl = "~/Vehicle/Orange/Armored Car.gif"; 
        StringBuilder buff = new StringBuilder();
        buff.AppendFormat("{0}.Markers = null;{0}.clearOverlays();", GoogleMap1.ClientMapID); 
        buff.AppendFormat("{0}.addMarker(", GoogleMap1.ClientMapID)
             .Append("{")
             .AppendFormat("Latitude:{0},Longitude:{1},ImageUrl:'?',IconAnchor:'?',IconSize:'?'", JsUtil.Encode(56.591565), JsUtil.Encode(84.912045))
             .Append("});");
        }
        buff.AppendFormat("{0}.render();", GoogleMap1.ClientMapID);
        ScriptManager.RegisterClientScriptBlock(this, GetType(), "_Test", "Sys.Application.add_load(function() {" + buff.ToString() + ";});", true);
    }
}