Initializes a new instance of the Marker class. Creates a new instance of a Marker

Namespace: Reimers.Google.Map
Assembly: Reimers.Google.Map (in Reimers.Google.Map.dll) Version: 5.3.95.699 (5.3.95.699)

Syntax

C#
public Marker(
	Guid id,
	double latitude,
	double longitude
)

Parameters

id
Type: System..::..Guid
The ID of the Marker
latitude
Type: System..::..Double
The latitude of the Marker's location as Double.
longitude
Type: System..::..Double
The longitude of the Marker's location as Double.

Examples

The code below shows how to read marker information from a database and create the appropriate markers.

CopyC#
DataTable dt = new DataTable();
//Dummy polygon for the sake of example.
Polygon polygon = new Polygon();
//Set up the database connection.
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection("Your connection string");
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(
    @"SELECT ID, Lat, Lng, Text FROM Overlays 
    WHERE Lat < @MaxLat AND Lat > @MinLat AND Lng < @MaxLng AND Lng > @MinLng",
    conn);
cmd.Parameters.AddWithValue("@MaxLat", polygon.Bounds.MaxLatitude);
cmd.Parameters.AddWithValue("@MinLat", polygon.Bounds.MinLatitude);
cmd.Parameters.AddWithValue("@MaxLng", polygon.Bounds.MaxLongitude);
cmd.Parameters.AddWithValue("@MinLng", polygon.Bounds.MinLongitude);
conn.Open();
SqlDataReader dtr = cmd.ExecuteReader();
while (dtr.Read())
{
    Marker marker = new Marker(
        (string)dr["ID"],
        (double)dr["Lat"],
        (double)dr["Lng"]
        );
    Map.Overlays.Add(marker);
}
dtr.Close();
conn.Close();
CopyVB.NET
Dim conn As New SqlConnection("Your connection string")
Dim cmd As New SqlCommand("SELECT ID, Lat, Lng, Text FROM Overlays", conn)

conn.Open()

Dim dtr As SqlDataReader = cmd.ExecuteReader
While dtr.Read
    Dim marker As New Marker
    marker.theID = dtr("ID").ToString
    marker.Latitude = CType(dtr("Lat"), Double)
    marker.Longitude = CType(dtr("Lng"), Double)
    marker.MarkerText = dtr("Text").ToString
    Map.Overlays.Add(marker)
End While

dtr.Close()

conn.Close()

See Also