Fire click event on a Marker from a link

Apr 13, 2009 at 1:28 PM
Is there a way to fire the 'click' event or any marker event from something other than the marker itself?  I have a list of links outside the google map that displays information about each marker.  I would like the user to be able to click on the link and have the marker show its info window.
Coordinator
Apr 13, 2009 at 8:27 PM
Edited Apr 13, 2009 at 8:33 PM
Hi there,

You can actually invoke the openInfoWindowHtml JS function for the required marker.
Here is a simple sample code:

<artem:GoogleMap ID="GoogleMap1" runat="server" Width="634px" Height="600px" Latitude="42.1229"

    Longitude="24.7879" Zoom="4" EnableScrollWheelZoom="true" OnClientClick="addMarker">

    <Markers>

        <artem:GoogleMarker Latitude="42.1229" Longitude="24.7879" Title="Click on the marker"

            Text="Text of marker 1" Draggable="true">

        </artem:GoogleMarker>

        <artem:GoogleMarker Latitude="42.1229" Longitude="24.7879" Title="Click on the marker"

            Text="Text of marker 2" Draggable="true">

        </artem:GoogleMarker>

    </Markers>

</artem:GoogleMap>

 

<a href="javascript:showInfoWindow(0);">Show first marker</a>

<a href="javascript:showInfoWindow(1);">Show second marker</a>

 

<script type="text/javascript">

    function showInfoWindow(index) {

        var marker = <%= GoogleMap1.ClientID %>.Markers[index];

        marker.openInfoWindowHtml(marker.Text);

    }

</script>


Note, I'm using the marker's Text to show in the info window, but actually you can pass any HTML content there.

Hope this helps...
Regards

Apr 15, 2009 at 2:39 PM
Thanks velio, that works perfect.
Feb 18, 2010 at 4:24 PM

Hi

I try Google Map control everything works fine as needed but just one questionfor the masterpage

I have dataview list where i bind the data based on zipcode and return dataset.Google map control works perfect showing the markers and info window but i also added hyerlink in dataview list and on click event i called javascript at the content page

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

<

</font></font><font size="2" color="#0000ff">

 

</font>

script type="text/javascript"> <font size="2">

 

</font>

function showInfoWindow1(index) {

var marker = <%= GoogleMap1.ClientID %>.Markers[index];

 marker.openInfoWindowHtml(market.text);}

</script> i pass index value from code behind at databound here is my code

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

Private

</font></font><font size="2" color="#0000ff">

 

</font>

Sub dlZonStores_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles dlZonStores.DataBoundDim marker As Artem.Web.UI.Controls.GoogleMarker

Dim address As String ,Dim int As Integer ,Dim hypClick As DevExpress.Web.ASPxEditors.ASPxHyperLink  

 hypClick =int = dlZonStores.Items(i).Index

hypClick.Text ="Click for More info"

<font size="2">

 

</font>

For i As Integer = 0 To dlZonStores.Items.Count - 1Dim item As DataViewItem = dlZonStores.Items(i)DirectCast(dlZonStores.FindItemControl("hypClick", item), DevExpress.Web.ASPxEditors.ASPxHyperLink)

address = dlZonStores.Items(i).DataItem("ADDRESS1") & dlZonStores.Items(i).DataItem("CITY") & dlZonStores.Items(i).DataItem("STATE") & dlZonStores.Items(i).DataItem("ZIPCODE")

hypClick.Attributes.Add("onclick", "javascript:showInfoWindow1(" + int.ToString() + ")")  'javascript called using hyperlink

<font size="2">

marker =

</font>

New Artem.Web.UI.Controls.GoogleMarker(address)

Next <font size="2">

 

</font>

End Sub

above code work fine in regular page without master page but when i paste the same code in master page i do not get marker text back it give javascript error marker is null please help me if you can let me know if you need anything else for the explanation.

 

thanks ketty

 

 

Sep 28, 2010 at 3:12 PM

I have the same problem about masterpage! Have you find the problem?

 

Thanks

Mazdak