My first Virtual Earth post
So I’ve got a page with a virtual earth map into which I load a bunch of shapes. When the user mouses over a shape, I wanted the fill color to change and the infobox to popup. My initial plan was to use onmouseover and onmouseout but I found that when you mouse over the infobox, the onmouseout event fires. So instead of using the onmouseover and onmouseout events, I handled everything in onmousemove and keep track of my ‘current’ shape (_currentWatershed). I also check to see whether the shape the mouse is over is the same as the _currentWatershed and if so, I don’t do anything.
function mouseMoveHandler(e)
{
if (e.elementID == null)
{ //if we moused off all features
//and there was a _currentWatershed set
if (_currentWatershed != null)
{
_currentWatershed.SetFillColor(_watershedsFillColor);
_map.HideInfoBox(_currentWatershed);
_currentWatershed = null;
}
}
else
{
var shape = _map.GetShapeByID(e.elementID);
if (shape != null &&
shape.GetShapeLayer() == _watershedsLayer &&
shape != _currentWatershed)
{
if (_currentWatershed != null)
_currentWatershed.SetFillColor(_watershedsFillColor);
_currentWatershed = shape;
_currentWatershed.SetFillColor(_watershedsHoverFillColor);
_map.HideInfoBox();
//shows the infobox at the mouse position when this event fires
_map.ShowInfoBox(_currentWatershed, new VEPixel(e.mapX, e.mapY));
}
}
}
August 8th, 2008 at 2:34 pm
Ahhhhh Mike! Indent your code! Just playing
Looks great! Perfect start for your blog, something simple.
Congratz!
August 16th, 2008 at 8:56 am
Yeah, I know. I wasn’t sure how to get WordPress to do that. Just figured it out though: the html
February 16th, 2009 at 11:44 am
Mike, if you are interested in creating a tile overlay map for your simple VE app, please take a look at MapDotNet UX.
You can try our parcel overlay map now just by adding the following code…
function GetTiles()
{
var bounds = [new VELatLongRectangle(new VELatLong(32,-85),new VELatLong(30,-83))];
var tileSourceSpec = new VETileSourceSpecification(“parcels”, “http://services.parcelatlas.com/MapTileHandler.ashx?qkey=%4&contractid=D3342484-32CD-DD11-AF04-0003FF70C8AE”);
tileSourceSpec.NumServers = 1;
tileSourceSpec.Bounds = bounds;
tileSourceSpec.MinZoomLevel = 1;
tileSourceSpec.MaxZoomLevel = 20;
tileSourceSpec.Opacity = 1.0;
tileSourceSpec.ZIndex = 100;
map.AddTileLayer(tileSourceSpec, true);
}