Posted by david on 25. November 2008 21:57
progress
counts are working, though only manually. There must be a timer or way to check existence of the layer to make sure it was completely loaded.
Importing a dataset creates two layers. Shouldn’t. don’t know why it is yet.
got the layer text working, too.
Seems like I should load the georss into a independent data set, import seems to be flaky.
Next steps:
- connect to the old divesite db
- investigate loading into a dataset prior to populating map.
- figure out why the two layers are being added during the import.
- how to access map from client side code ( everything is still all server side )
- change icons on the hurricane points
Virtual Earth Tile System
Invoking server side code using AJAX and .ashx handlers
Microsoft Virtual Earth
Mashup Library
Shapefile - Wikipedia, the free encyclopedia
Showing ESRI Shapefile Layers on a Virtual Earth Map a simple HowTo
how-to-convert-arraylist-to-dataset
Posted by david on 24. November 2008 08:21
current sandpit is the shape counting.
scenario:
open up page. click add hurricane. layer count increments by one, shape count does not.
sometimes, after adding ageo, the count will come up. but only for the last add.
current hypothesis:
there is a delay, a lag, when loading shapes, esp by importing into a layer. the call to the update counts code is happening before the lag. so update counts doesn’t see the shapes yet.
so, going to try using the callback function on the ImportShapeLayer
ok, scratch that, seems to be a lot of controversy about using those
but this guy says its ok …
Matt Berseth ASP.NET AJAX Invoke a static method from script
first efforts failed …
I did confirm that the delay is causing the problem: i threw another button on the page attached to the update method … adding a layer did not correctly increment the shape count, but the update button did.
Why do ASP.NET AJAX page methods have to be static Encosia but static page methods dont have access to controls.
Ok – to summarize: the original problem was that shapecount was not correct. update counts is called immediately after the add layers methods. importing takes time & the lag causes the update count to miss the newly added shapes.
My first response was to try and call the update method from javascript. but pagemethods cannot access the controls, which is what i’m trying to do, update the control with the counts.
Second response was to double check that there was indeed a lag & that an update of the counts – after the import acutally completed – worked.
Since I don’t feel like jumping into the pagemethod stuff, if that is even the ultimate solution, I’m going to code the count updates client side in javascript. Hopefully there won’t be any issues with the other server side counts.
Importing and Mapping Data
Keith Kinnan's Blog Virtual Earth API GeoRSS Layers
How do you get client side instance of asp.net map control Virtual Earth Map Control Development
Posted by david on 21. November 2008 22:35
finally really getting somewhere with the map … in c# using the .net control.
after treading water for several sessions, I’ve got this
all dot net, no side script … yet
trying to access counts …
first, from the AddHurricane, I was able to get a layercount (2) but not a shapecount (0). I think there is a default base layer, plus the hurricane. not sure why it didn’t calculate the shapecount.
but at least I’ve got the writing back to the client thing working …
GIS in XML » Blog Archive » Virtual Earth - DeepEarth - Deep Pockets
DeleteAllShapes and DeleteAllShapeLayers is not working Virtual Earth Map Control Development Wi
this post resolved the trouble I was having with layer counts … the map control has a property “SendLayersToServers” … by default it is set to fault, by setting to true, the layers are persistent & counts work correctly.
weirdness: adding the hurricane layer actually adds 2 layers,
ok, think that was my layer count code.
C# - StringBuilder Secrets
MSDN Call JScript from C#
geocoding Virtual Earth Map Control Development Windows Live Developer Forums MSDN Forums
How to use the virtual earth winforms user control part 2 Adding pushpins
how to retrieve list of the map pushpins & shapes to iterate through Virtual Earth Map Control D
Adding a Pushpin to Virtual Earth Map - ASP.NET Forums
Posted by david on 17. November 2008 21:01
trying to find out how to customize pushpin for the layer … seems like the only way to do is loop through all shapes of the layer, setting them individually:
javascript: ( source )
function onFeedLoad(layer)
{
var numShapes = layer.GetShapeCount();
for(var i=0; i < numShapes; ++i)
{
var s = layer.GetShapeByIndex(i);
s.SetCustomIcon("<img src='hiking_icon.gif'/>");
}
}
which actually is cool because while stepping through you can apply logic to decide which shape you want to see for that particular data point:
the slightly irritating thing about c# is that you can never seem to just do something … shape.setcustomicon … noooo first you gotta
4296
colinmackay.net Drawing Lines
colinmackay.net Using Pushpins
there’s a real lack of .net specific information out there – it’s all for the javascript control.
So, I’ve got the map loads in pageload with the following:
ShapeLayer aGeoRSSLayer = new ShapeLayer();
ScubaMap.AddShapeLayer(aGeoRSSLayer);
ScubaMap.ImportShapeLayerData(new ShapeSourceSpecification(DataType.ImportXML, "http://david.egerton.info/Storage/1992hurricaneandrew.xml", aGeoRSSLayer), "", true);
I tried looping through the shape to set custom icon – didn’t work … I even tried deleting the shapelayer, after creating it, that didn’t work. Seems like I’ve lost access to it after it is sent to the map.
My next line of attack is to create the shapelayer myself, rather than use the importxml … following the Drawing Lines method in the above link.
Map Control
“Client events are handled as JavaScript functions that are declared within a <script> tag. All JavaScript event handling functions must have the same signature, where OnClientEventHandler is the name of the JavaScript function that handles the event.”
Using JavaScript Along with ASP.NET
ASP.NET AJAX Overview ScriptManager Control Overview
The control follows the ASP.NET AJAX architecture so all properties of the control are exposed using the getters and setters.
You can use the $find(mapcontrolID) to get the control and then call:
get_VEMap()to get the actual VEMap object, then use as normal VE js control. You can also use this to set properties, call methods, bind to events etc. In debug mode the javascript is well laid out, in release mode it is compressed, at least it should be.
In order to get the map's control ID you need to expose the Map1.ClientID to javascript. I normally do this in my aspx page by doing this (assuming the map is ID=Map1:
<script type="text/javascript">
1:
2: var cMapControlID = '<% =Map1.ClientID %>';
</script>
then you can get the map object at run time like this:
var mymap = $find(cMapControlID).get_VEMap()
(source)
Virtual Earth Basics Series Part 1 – Loading the Map - Virtual Earth- Map Control Development -
so, what it looks like is that
the map is loaded from server to client … after that, server can’t touch it, at least at this point.
to deal with it at the client level, I’ve got to use javascript.
for a sec, it seems like there’s not much point to the .net control after all … but everytime something happens on the map, it can fire off server events. I just don’t know what they are yet. I’ve got a fresh page & am now going to try working at the client with the javascript, because it seems that’s where I have to do any manipulation of the layer, once that layer has been laid down. I’m also aiming at keeping any script off the page, in another file, so a, it’ll be clean and b, I can use it again.
Posted by david on 17. November 2008 14:41
Things improve quickly now – I was able to add a whole layer in about 10 minutes, here
public partial class Storage_2008_11_17_load_with_rss_set_of_data : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ShapeLayer aGeoRSSLayer = new ShapeLayer();
ScubaMap.AddShapeLayer(aGeoRSSLayer);
ScubaMap.ImportShapeLayerData(new ShapeSourceSpecification(DataType.ImportXML, "http://david.egerton.info/Storage/1992hurricaneandrew.xml", aGeoRSSLayer), "", true);
}
}
}
Posted by david on 16. November 2008 22:02
So – next step is to see if my earlier problems were due to the controls being buried inside of divs.
I’m going to try & nest the map control, with no other changes, into a styled page:
front code:
1: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="2008_11_16_addWorkingMapIntoDivs.aspx.cs" Inherits="Storage_2008_11_16_addWorkingMapIntoDivs" %>
2: <%@ Register Assembly="Microsoft.Live.ServerControls.VE"
3: Namespace="Microsoft.Live.ServerControls.VE"
4: TagPrefix="ve" %>
5:
6: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
7: <html xmlns="http://www.w3.org/1999/xhtml">
8: <head runat="server">
9: <title>Untitled Page</title>
10: <link href="DiveStyle.css" rel="stylesheet" type="text/css" />
11: </head>
12: <body>
13: <form id="form1" runat="server">
14: <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
15: </asp:ScriptManager>
16:
17: <%
1: -- TopBar --
%>
18: <div id='TopBar'>
19: </div>
20: <%
1: -- End TopBar --
%>
21:
22: <%
1: --3ColumnsWrap -----------------------------------------------------------------
%>
23: <div id='3ColumnsWrap'>
24:
25: <%
1: -- contentHeader ( for response display ) --
%>
26: <div id='contentHeader'>
27: </div>
28: <%
1: -- End contentHeader --
%>
29:
30: <%
1: -- LeftBar--------------
%>
31: <div id='LeftBar'>
32: </div>
33: <%
1: -- End LeftBar --------------
%>
34: <%
1: -- CenterBar--------------
%>
35: <div id='CenterBar'>
36:
37: <%
1: -- mapContainer--------------
%>
38: <div id='mapContainer'>
39: <ve:Map ID="ScubaMap" runat="server" Height="600px" Width="600px"
40: ZoomLevel="4" />
41: </div>
42: <%
1: -- End mapContainer--
%>
43:
44: </div>
45: <%
1: -- End CenterBar--
%>
46:
47: </div>
48: <%
1: -- End 3ColumnWrap--
%>
49:
50: </form>
51: </body>
52: </html>
behind code:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.Live.ServerControls.VE;
using System.Collections.Generic;
public partial class Storage_2008_11_16_addWorkingMapIntoDivs : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Seattle
AddShape(47.60384, -122.33002);
}
private void AddShape(double latitude, double longitude)
{
LatLongWithAltitude point = new LatLongWithAltitude(latitude, longitude);
Shape shape = new Shape(ShapeType.Pushpin, point);
ScubaMap.AddShape(shape);
}
}
& guess what - it works just fine …. so nesting the control inside divs did nothing …
Posted by david on 16. November 2008 21:47
was still having trouble talking to the map … could get it to load, but could never get the page load firing. Probably some very basic noob error.
So, I started over … blank page, copied code from here
& it works here
so, now, I’m going to take things step by step & keep track of what I’m doing, so hopefully I won’t get lost in the wilderness again.
code behind for that working page:
1: using System;
2: using System.Collections;
3: using System.Configuration;
4: using System.Data;
5: using System.Linq;
6: using System.Web;
7: using System.Web.Security;
8: using System.Web.UI;
9: using System.Web.UI.HtmlControls;
10: using System.Web.UI.WebControls;
11: using System.Web.UI.WebControls.WebParts;
12: using System.Xml.Linq;
13: using Microsoft.Live.ServerControls.VE;
14: using System.Collections.Generic;
15:
16: public partial class Storage_2008_11_16_working_mapwith1pin : System.Web.UI.Page
17: {
18: protected void Page_Load(object sender, EventArgs e)
19: {
20: // Seattle
21: AddShape(47.60384, -122.33002);
22: }
23:
24: private void AddShape(double latitude, double longitude)
25: {
26: LatLongWithAltitude point = new LatLongWithAltitude(latitude, longitude);
27: Shape shape = new Shape(ShapeType.Pushpin, point);
28: ScubaMap.AddShape(shape);
29: }
30: }
front code:
1: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="2008_11_16_working_mapwith1pin.aspx.cs" Inherits="Storage_2008_11_16_working_mapwith1pin" %>
2: <%@ Register Assembly="Microsoft.Live.ServerControls.VE"
3: Namespace="Microsoft.Live.ServerControls.VE"
4: TagPrefix="ve" %>
5: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6:
7: <html xmlns="http://www.w3.org/1999/xhtml">
8: <head runat="server">
9: <title>Untitled Page</title>
10: </head>
11: <body>
12: <form id="form1" runat="server">
13: <asp:ScriptManager ID="ScriptManager1" runat="server">
14: </asp:ScriptManager>
15: <div>
16: <ve:Map ID="ScubaMap" runat="server" Height="400px" Width="400px"
17: ZoomLevel="4" />
18: </div>
19: </form>
20: </body>
21: </html>
Posted by david on 15. November 2008 22:54
Downloaded the Windows Live CTP to get the map controls …
freaking cool
started working with it here
turns out that you have to specify a map size in properties … map properties don’t work with percents … which seems to have worked in the javascript methods … funny because in VS, putting the sizes to 100% DID max out the map size within the container.
Virtual Earth Basics Part 1 – Loading the Map - LiveSide - Developer Blog - LiveSide - Windows L ( actually this is for the javascript control )
Drawing lines on the map with the Virtual Earth ASP.NET control
Using PushPins with the Virtual Earth ASP.NET control
map is loading – but I can’t get shapes to load … seems like the code behind is not recognizing the map .. but I can’t find the difference between my code & the sample code I’ve been looking at.
Posted by david on 15. November 2008 19:25
Virtual Earth, An Evangelist's Blog - Announcing the Virtual Earth ASP .Net Server Control
oh thank u, bill, u hunk of burnin love
“Don't like JavaScript? You want your managed code with the new wave of AJAX maps? Well, the long awaited Virtual Earth ASP .Net Server Control is now available for download as a part of the Windows Live Tools for Microsoft Visual Studio.”