Gallery
Click Map Projected
<%@ Page Language="C#" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="dotnetCHARTING.Mapping" %>
<script runat="server">
void Page_Load(Object sender,EventArgs e)
{
Chart.Type = ChartType.Map;
Chart.Size = "600x350";
Chart.TempDirectory = "temp";
Chart.Debug = true;
//Chart.Title = ".netCHARTING Sample";
Chart.Visible = false;
Chart.ChartArea.Label.Text = "Please click on a point on this map";
Chart.ChartArea.Background = new Background(Color.FromArgb(142,195,236),Color.FromArgb(63,137,200),90);
Chart.Mapping.DefaultShape.Background.Color = Color.LightGray;
// Demonstrates adding a point to a projected map based on lat/long coordinates of the click.
// FullScreen
Chart.Mapping.MapLayerCollection.Add(@"../../images/MapFiles/primusa.shp");
Bitmap bp = null;
Chart.Mapping.Projection.Type = ProjectionType.LambertConic;
Chart.Mapping.Projection.Parameters = "-50,10,-10,50";
if(Page.Request.Params["y"] != null && Page.Request.Params["x"] != null)
{
// Generate the chart in order to get the correct coordinates from the click position.
bp = Chart.GetChartBitmap();
// Get x and y points
int x = Convert.ToInt32( Page.Request.Params["x"]);
int y = Convert.ToInt32(Page.Request.Params["y"]);
PointF p = Chart.Mapping.GetLatLongCoordinates(new Point(x,y));
// Create a layer with a point at the clicked position.
MapLayer layer2 = new MapLayer();
layer2.AddLatLongPoint(p,new ElementMarker(ElementMarkerType.Circle,8,Color.Red));
Chart.Mapping.MapLayerCollection.Add(layer2);
iLabel.Text+="<BR>Latitude: " + p.X + " Longitude: " + p.Y;
}
// Generate the chart again to show the added point.
bp = Chart.GetChartBitmap();
string fileName = Chart.FileManager.SaveImage(bp);
imageLabel.Text += "<input type=image value=\"submit\" border=0 src=\"" +fileName+ "\" ISMAP>";
bp.Dispose();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title> </head>
<body>
<div align="center">
<form method =get >
<asp:Label ID=imageLabel Runat=server/>
</form>
<dotnet:Chart id="Chart" runat="server"/>
<asp:Label ID="iLabel" Runat=server></asp:Label>
</div>
</body>
</html>
<%@ Page Language="vb" Description="dotnetCHARTING Component" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="dotnetCHARTING.Mapping" %>
<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Chart.Type = ChartType.Map
Chart.Size = "600x350"
Chart.TempDirectory = "temp"
Chart.Debug = True
'Chart.Title = ".netCHARTING Sample";
Chart.Visible = False
Chart.ChartArea.Label.Text = "Please click on a point on this map"
Chart.ChartArea.Background = New Background(Color.FromArgb(142,195,236),Color.FromArgb(63,137,200),90)
Chart.Mapping.DefaultShape.Background.Color = Color.LightGray
' Demonstrates adding a point to a projected map based on lat/long coordinates of the click.
' FullScreen
Chart.Mapping.MapLayerCollection.Add("../../images/MapFiles/primusa.shp")
Dim bp As Bitmap = Nothing
Chart.Mapping.Projection.Type = ProjectionType.LambertConic
Chart.Mapping.Projection.Parameters = "-50,10,-10,50"
If Not Page.Request.Params("y") Is Nothing AndAlso Not Page.Request.Params("x") Is Nothing Then
' Generate the chart in order to get the correct coordinates from the click position.
bp = Chart.GetChartBitmap()
' Get x and y points
Dim x As Integer = Convert.ToInt32(Page.Request.Params("x"))
Dim y As Integer = Convert.ToInt32(Page.Request.Params("y"))
Dim p As PointF = Chart.Mapping.GetLatLongCoordinates(New Point(x,y))
' Create a layer with a point at the clicked position.
Dim layer2 As MapLayer = New MapLayer()
layer2.AddLatLongPoint(p,New ElementMarker(ElementMarkerType.Circle,8,Color.Red))
Chart.Mapping.MapLayerCollection.Add(layer2)
iLabel.Text &= "<BR>Latitude: " & p.X & " Longitude: " & p.Y
End If
' Generate the chart again to show the added point.
bp = Chart.GetChartBitmap()
Dim fileName As String = Chart.FileManager.SaveImage(bp)
imageLabel.Text &= "<input type=image value=""submit"" border=0 src=""" & fileName & """ ISMAP>"
bp.Dispose()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.netCHARTING Sample</title> </head>
<body>
<div align="center">
<form method =get >
<asp:Label ID=imageLabel Runat=server/>
</form>
<dotnet:Chart id="Chart" runat="server"/>
<asp:Label ID="iLabel" Runat=server></asp:Label>
</div>
</body>
</html>
- Sample FilenameClickMapProjected.aspx
- Version4.1
- Uses DatabaseNo