Pär 0 Comments

I haven't blogged for a while... I've been busy working.

A couple of week ago a came across some really lousy maps at a web site that belongs to a customer and thought that there must be something better. So a went along playing with Virtual Earth, and was surprised how easy it was. All I had to do was add some java script:

<script src="http://dev.virtualearth.net/mapcontrol/v4/mapcontrol.js"/></script>

place a div on my page:

<div id='myMap' style="position:absolute; width:400px; height:400px;"></div>

create (or actually copy...) a function for loading the map, center it over the right spot and place a push pin:

var theMap = null;
PinID = 1;

function GetMap()
{
    theMap = new VEMap('myMap');

    var startCenter = new VELatLong(59.3115, 18.0722);
    var startZoom = 8;

    theMap.LoadMap(startCenter, startZoom);
    theMap.HideDashboard();
    theMap.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers); // Yes, I'm from Europe...
    theMap.AddPushpin(new VEPushpin(nextPinID++,
	new VELatLong(59.3115, 18.0722),
	null, 'This...', '...is the place.'));

} 

and finally call the function at a proper moment:

<body onload="GetMap();">

That's pretty much it. But of course, I went along creating an ascx control that encapsulated all this and simplified the handling of push pins and areas to make it easier to use within a real asp.net site. And yes, I'm aware that it already exist such a control on Codeplex (PietschSoft.VE), probably much, much better than mine, but I did it for fun... and to gain some knowledge.

 

Read more: