|
Thank you for responding.
That piece of code is in the aspx file as shown:
<% @ Page Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="Mapping.aspx.cs"
Inherits="FNMWatchListDashboard.Mapping" Title="Fannie Mae WatchList Dashboard - Mapping" %>
<% @ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<% @ Register Assembly="Simplovation.Web.Maps.VE" Namespace="Simplovation.Web.Maps.VE"
TagPrefix="Simplovation" %>
<% @ Register Assembly="Simplovation.Web.Maps.VE" Namespace="Simplovation.Web.Maps.VE.Extenders"
TagPrefix="MapExtenders" %>
< asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server" />
< asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:ScriptManager runat="server" ID="ScriptManager1" />
<script type="text/javascript">
function MapShowBestFit()
{
var map = $find("<%=Map1.ClientID%>");
//This code will center the map on all the shapes that are plotted
var locations = new Array();
for(var a = 0; a < map.get_Map().GetShapeLayerCount(); a++)
{
for(var b = 0; b < map.get_Map().GetShapeLayerByIndex(a).GetShapeCount(); b++)
{
Array.add(locations, map.get_Map().GetShapeLayerByIndex(a).GetShapeByIndex(b));
}
}
if (locations.length != 0)
map.get_Map().SetMapView(locations);
}
</script>
/*
Other Controls on the page
*/
< div id="mapping">
<asp:Label ID="lblMapPointCount" runat="server"></asp:Label>
<Simplovation:Map runat="server" ID="Map1" Width="636px" Height="445px" CssClass="map" Zoom="3" OnClick="Map1_OnClick" />
</div>
</ asp:Content>
And the server side code looks like this
//Plot the points
int mapPointCount = 0;
Map1.Layers.Clear();
foreach (MapPoint mapPoint in mapPoints)
{
if (mapPoint.Latitude != DBNull.Value && mapPoint.Longitude != DBNull.Value)
{
Simplovation.Web.Maps.VE. Shape s = new Simplovation.Web.Maps.VE.Shape(new Simplovation.Web.Maps.VE.LatLong(Convert.ToDouble(mapPoint.Latitude), Convert.ToDouble(mapPoint.Longitude)));
s.Title = mapPoint.Title == null ? String.Empty : mapPoint.Title.ToString();
s.Description = mapPoint.Description == null ? String.Empty : mapPoint.Description.ToString();
Map1.AddShape(s); mapPointCount++;
}
}
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "showbestfit", "MapShowBestFit();", true);
And when this code is executed, I am getting a javascript error: Microsoft JScript runtime error: 'null' is null or not an object. I placed a debugger in the javascript code and var map = $find("<%=Map1.ClientID%>"); ie.,
var map = $find("ctl00_ContentPlaceHolder1_Map1");
line returns a null, so it blows on map.get_Map().
I am using .NET 3.5 Framework and Web.Maps.VE 2.0 version now.
Thank you in advance.
|