SetMapView using Javascript

Last post 7/1/2009 7:54:03 AM by nsfranklin. 2 replies. << Back to Web.Maps.VE v2.0 General
6/30/2009 9:42:00 AM
nsfranklin

SetMapView using Javascript

Hi I'm using your script from version 1 to set my map view to zoom into the map and centre where all locations are visible. This works fine for the first time into the map, but subsequent refreshes the map zooms out to the original position and the mapLoaded script does not run. I'm using OnClientMapLoaed="mapLoaded" to set the map view.
6/30/2009 10:13:55 PM
Chris Pietschmann

Re:SetMapView using Javascript

Are you using the Web.Maps.VE Map control within an UpdatePanel? If so, you'll want to remove it from the UpdatePanel, as it is not supported to use Web.Maps.VE inside an UpdatePanel since it is designed to be used along side other UpdatePanels on the page.

If you aren't using Web.Maps.VE within an UpdatePanel and are still having this problem, could you please post some sample code that demonstrates the issue, so I can troubleshoot it further? Thanks.
7/1/2009 7:54:03 AM
nsfranklin

Re:SetMapView using Javascript

Hi Chris

No I'm not using the control inside an update panel, so code from page is here.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ve-live.aspx.vb" Inherits="_Default" %>

<%@ Register assembly="Simplovation.Web.Maps.VE" namespace="Simplovation.Web.Maps.VE" tagprefix="Simplovation" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title>Mapping</title>

</head>

<script type="text/javascript">

// This method is run once the map has completed loading on the page

function mapLoaded()

{

var map = $find("<%=ve_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.addRange(locations, map.get_Map().GetShapeLayerByIndex(a).GetShapeByIndex(b).GetPoints());

}

}

if (locations.length != 0)

map.get_Map().SetMapView(locations);

}

</script>

<body>

<form id="form1" runat="server">

<asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="6000">

<%-- <Scripts>

<asp:ScriptReference path="~/PageRequestManagerEx.js"/>

</Scripts>--%>

</asp:ScriptManager>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">

<ContentTemplate>

<asp:Timer ID="Timer1" runat="server" Interval="10000" OnTick="Timer1_Tick">

</asp:Timer>

</ContentTemplate>

</asp:UpdatePanel>

<div id="divMapContainer" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;">

<Simplovation:Map OnClientMapLoaded="mapLoaded" ID="ve_map1" runat="server" Width="100%" Height="100%"

DashboardSize="Small"

OnChangeView="ve_map1_ChangeView" Latitude="54.62864" Longitude="-2.967205"

Zoom="6">

</Simplovation:Map>

</div>

</form>

</body>

</html>

 

Thanks