Our Friends

MP2K Mag

Recent Blog Posts RSS

ViaWindowsLive on Via Virtual Earth Blog

The new ViaWindowsLive community site has launched and features not only a definitive set of resources on all Live Services from Microsoft but also a special section on Virtual Earth including a new site gallery for you to upload your sites, new articles on Version 6, including getting started guide, an interactive quick guide, location finder and more. Subscribe to the VWL aggregated blog to stay in touch with everything Live Services related. Find all the great content from this site and much, much more. Explore how other Live Services can compliment Virtual Earth and your applications.

Version 5 URL changed - Error: 'VEMap' is undefined on Via Virtual Earth Blog

It has been reported that the old url to access the Version5 javascript for Virtual Earth no longer works. This is effecting sites worldwide.

The correct way to reference the Version 5 javascript is:

<script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5"></script>

If you have been effected a forum thread has been started here

Silverlight Virtual Earth viewer on Via Virtual Earth Blog

With the launch of silverlight yesterday I was digging around and found this viewer for Virtual Earth by Greg Schechter. It does use the 1.1 alpha of silverlight. It gives some interesting ideas for where Virtual Earth could be headed. Certainly the demo of the performance of silverlight compared to javascript for processing showed a significant increase. This could be very useful.

And of course on the gamer front check this out by Andy Beaulieu and shoot down some UFO's over Birdseye images.

John.

So much new Virtual Earth Imagery Worldwide. on Via Virtual Earth Blog

I subscribe to all the VE blogs and recently the posts about updated imagery has been more and more frequent.

The latest is here and for myself downunder we saw three updates, Canberra, Newcastle and Uluru:

CanberraAUUluruAUNewcastleAU

Derek Chan posts 3 Articles in a month! on Via Virtual Earth Blog

A big thank you to the efforts of Derek Chan who posted his third VE article today (he actually had it ready weeks ago but had to wait for Mr Bottleneck here at VVE ;) )

The 3 articles are all relivant to Version 5 of Virtual Earth and deal with the Mini Map, debugging javascript and now custom pins in routes.

All these can now be found in our articles section.

If you have something to contribute send us an email.

John (The bottleneck)

Virtual Earth Madness - Getting VE MapControl to place maps by Zip Code

Getting VE MapControl to place maps by Zip Code by (deleted user) on 3 Jul 06 @ 01:51:00 UTC

M5 for Version 3

OR

Getting VE MapControl to place maps by Zip Code

After trying for a few hours a day for a week to make M5 work I gave up and sent an e-mail to Dr Neil. His suggestion was to populate a hidden table. I either did it wrong or misunderstood, but I could not get it to work.

I was already playing with some other ideas and came up with another solution.

First, I attempted a straight forward approach that did not work in V2 but I tried anyway.

{

//read file

plzip=xmldso_list.recordset("zip");

var pCITYST=xmldso_list.recordset("cityst");

var pPHONE=xmldso_list.recordset("location");

var pNAME=xmldso_list.recordset("P2LMname");

var pall=pPHONE+' '+pCITYST+' '+plzip

map.Find('',plzip);//go to ooin after find

ooin();

}

The function ooin places the pins. All this did was to give me the last pin (or possibly all of them) in the center of the map.

This lead me, after quite some time, to the following solution. Call a pin placement function after I located the zip on a map, that is, after mapcontrol tells me it has located the zip. The problem is that you can't do that since the map.find() does not issue a callback if you use only the WHERE and not the WHAT. Then it occurred to me, just use the WHAT and WHERE, but what should I put in the WHAT field? My first approach was to pick something every zip code location had, a Post Office. Nice try, but it seems there could be several Post Offices in each current view. So I tried selecting something that would not be there, like the name of the person living at the location I was looking for. In retrospect that is not really the best solution because if the location is say, City Hall, that would be a valid WHAT and a pin will get placed there. Perhaps "QWERTY" entered into the WHAT field would be better. Actually, it really does not matter much since the user never sees the map I issue the find on anyway, you will see what I mean below.

The only problem with this approach, that I can see, is that it displays an error message "No Results Were Found".

To solve that problem I think I should be able to turn off the error message but so far all attempts to do so have failed. So I am ignoring it for now.

Another issue is the moving around the globe as the pins are placed. I just didn't like that. So I cheated, I made the map 68x1px, almost invisible. Any smaller and I get an error. Then I placed a second map on the page where I placed pins by lat and lng. By placing the little map last on the page you may not even notice the error message. (If someone has the answer here I would be glad to hear it.

(Want instant gratification? Here is a working copy: http://www.lamonica.net/MAP/map5e.htm)

So here is the code I settled on so far.

The standard HTML stuff and then declare some variables.

<html>

<head>

<title></title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

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

<script>

var map = null;//Map

var pPOINT = new Array();//set array for call back to center

var plzip;//holds zip field from xml file

var pinID=1; //Pin ref number

var PLPinNo;//record no.

var pin;//used when placing pin

var pli;//recordcount

var loc; //first pin

This next bit just sets up the two maps, then goes to the top of the XML file and checks for the number of records:

function GetMap()

{

bigmap = new VEMap('PLSBIGMap');

bigmap.LoadMap();

map = new VEMap('plMap');

map.LoadMap();

Part II: Getting VE MapControl to place maps by Zip Code by LPeters on 3 Jul 06 @ 01:56:00 UTC

I noticed that my post was Truncated This is the rest- Read "Getting VE MapControl to place maps by Zip Code" first.

...

This next bit just sets up the two maps, then goes to the top of the XML file and checks for the number of records:

function GetMap()

{

bigmap = new VEMap('PLSBIGMap');

bigmap.LoadMap();

map = new VEMap('plMap');

map.LoadMap();

bigmap.SetZoomLevel(3);

xmldso_list.recordset.moveFirst;

pli=xmldso_list.recordset.RecordCount ;

plgo();

}

This bit just reads some data from the XML file then the last line is what makes this all work. The "map.Find..." finds the location on the map, I have information in both WHAT and WHERE, because of that, after the location is returned the function ooin is called. If only WHERE is specified the function is never called, just the way the mapcontrol is set up I guess. If you specify only WHERE and try to simply place all the pins you will wind up with all the pins in the original center. I believe this happens because all the pins are placed before the first find is returned.

So here it is:

function plgo()

{

//read file

plzip=xmldso_list.recordset("zip");

var pCITYST=xmldso_list.recordset("cityst");

var pPHONE=xmldso_list.recordset("location");

var pNAME=xmldso_list.recordset("P2LMname");

var pall=pPHONE+' '+pCITYST+' '+plzip

map.Find('pNAME',pall,null,ooin);//go to ooin after find

}

The ooin function places the pins by reading data from the XML file then storing it in 'pin'. Note that the pin is added to the map "bigmap", and before in function plgo, the find was issued to the map "map". You don't have to do that but it makes the map look like it stays stationary while pines are placed. In reality the little 'map' is moving around out of view.

function ooin()

{

var plgc=map.GetCenter();

pPOINT.push(plgc);

plzip=xmldso_list.recordset("zip");

var pCITYST=xmldso_list.recordset("cityst");

var pPHONE=xmldso_list.recordset("location");

var pNAME=xmldso_list.recordset("P2LMname");

var pall=pPHONE+' '+pCITYST+' '+plzip

PLPinNo=xmldso_list.recordset.absoluteposition;//get record no for pin

pin = new VEPushpin(

pinID,

plgc,

null,

" "+pNAME+" ",

pall+' :number '+PLPinNo

);

bigmap.AddPushpin(pin);

The next line places information on the top of the page while the XML file is being read to give the user something to look at.

The line after that places the map center into an array so I can issue a SetMapView later.

Then finally add 1 to pinID:

td_P2L_LOCATION.innerHTML='Loading record: '+pNAME+', '+pall+'<br>Record '+PLPinNo+' of '+pli+' <i style=font-size:12 >(Error message will turn off when all redords are loaded)</i>';

pPOINT.push(map.GetCenter()); //add center to array to position map when done

pinID++;

Finally this part looks at the XML file to see if there are more records, if there are then it goes back to and starts again. If the last record has been read then the SetMapView sets the map view to include all pins (almost, the array is not populated correctly) and then changes the text on the top of the screen to report to the user that all pins are placed.

if (PLPinNo<pli)

//if there are more records go to plgo

{

xmldso_list.recordset.moveNext;

plgo();

}

else

{

bigmap SetMapView(pPOINT);//set map for best view based on pin loca

Part III: Getting VE MapControl to place maps by Zip Code by LPeters on 3 Jul 06 @ 01:59:00 UTC

I think this is the final part,

read "Getting VE MapControl to place maps by Zip Code"

then "Part II: Getting VE MapControl to place maps by Zip Code" then this.

Finally this part looks at the XML file to see if there are more records, if there are then it goes back to and starts again. If the last record has been read then the SetMapView sets the map view to include all pins (almost, the array is not populated correctly) and then changes the text on the top of the screen to report to the user that all pins are placed.

if (PLPinNo<pli)

//if there are more records go to plgo

{

xmldso_list.recordset.moveNext;

plgo();

}

else

{

bigmap SetMapView(pPOINT);//set map for best view based on pin locations;

td_P2L_LOCATION.innerHTML=pli+' records loaded';

}

}

</script>

The body of the page looks like this. Note that bigmap is first then map, that places map, and it's error message, at the bottom of the screen

</head>

<body onload="GetMap()">

<xml id=xmldso_list src="event5.xml" ></xml>

<table border="0">

<tr align="center"><td id="td_P2L_LOCATION"></td></tr>

<tr><td id="p"></td></tr>

</table>

<div id='PLSBIGMap' style="position:relative; width:600px; height:500px;"> </div>

<div id='plMap' style="position:relative; width:68px; height:1px;" ></div>

</body>

</html>

The xml file looks like this: (Note that some fields are not used in the map)

<?xml version="1.0" ?>

<pllm>

<event>

<image>NoPhoto.gif</image>

<emailA>ilipino@email.eml</emailA>

<date>b-day:05/03</date>

<P2LMname>Ida Lipino</P2LMname>

<location>11 Calabasa Street</location>

<cityst>Watsonville, California</cityst>

<zip>95076</zip>

<phone>(222) 555-1212</phone>

</event>

<event>

<image>NoPhoto.gif</image>

<emailA>jtaylor@email.eml</emailA>

<date>b-Day:05/06</date>

<P2LMname>James Taylor</P2LMname>

<location>Falabamalbrook Road</location>

<cityst>Fallbrook, California</cityst>

<zip>92028</zip>

<phone>(222) 555-1212</phone>

</event>

</pllm>

Oh, one more thing, I will leave the error checking routines to you, if you didn't notice I made no attempt to check for errors in the XML file or anything else.

RE: Getting VE MapControl to place maps by Zip Code by Acts7 on 3 Jul 06 @ 16:52:00 UTC

hey I have a fix for your error code popup - email me

eagle // no slashes or spaces // prop // at // hotmail.com

RE: Getting VE MapControl to place maps by Zip Code by Dr. Neil on 5 Jul 06 @ 23:21:00 UTC

Acts7, why dont you share it with the rest of us?

LPeters has been good enough to share is solution so far, please will you post the fix here?

Map M5: Getting VE MapControl to place (pins on) maps by Zip Code by LPeters on 10 Jul 06 @ 17:14:00 UTC

Despite an e-mail I have not heard from Acts7 about the error message. Should I get one I will post it, however, I would rather he places it here him (or her) self.

Also - I have added some items to the M5 map and I will be posting those. Being Summer time I have been sidetracked by some other things, so do not be surprised if they do not get posted until the end of the month.

The items added include a “how do get there from here”. Not hard, but you may find my approach interesting. Also I will include a ‘real world’ use for all this, I have promised some people that I will implement the map on a website, I will post the address when the map goes live.

For those of you like me living in the northern hemisphere, it’s Summer, shut off the monitor for a while and go outside. That big round glowing thing is the sun. If, while your out there, and get an idea that I can add to M5 let me know.

RE: Getting VE MapControl to place maps by Zip Code by (deleted user) on 22 Jun 07 @ 08:47:00 UTC

Hi All,

I have utilised the code above for my own project. I'm based in the UK so I'm using Post Code opposed to Zip Code. I am having a slight issue with the way my code works though. When I run the html page I can see that it loads each record, but this does not always translate into a PushPin being loaded on the map. Well that's not strictly true, it loads a PuhPin for the Postcode but as other Pushpins are added to the map, a Pushpin that had originally loaded OK is replaced by a later loaded PushPin (In the exact same location as the previously loaded one).

This can happen with as little as 3 records. So, the 1st one loads, the second one loads, replaces the 1st (by description, the pushpin remains in the same location as record 1) and finally the 3rd loads OK.

I have played with this for a while. I have noticed it seems to happen when there are similar Post Codes loaded sequentially one after the other i.e. M13 3AS UK, M7 3BB UK, M2 QBB UK, etc. If these Post Codes are interspersed with other (completely different) postcodes i.e. LL13 9BT UK, CH3 2WQ UK etc, they seem to load and add a Push Pin more succesfully.

Obviously getting my SQL script to randomise postcodes is not something I can/want to acomplish.

This would suggest that the Javascript is correct and it's an issue with VE, Is anyone aware of this?

Help much appreciated (Hittng head against a brick wall!)

Thanks

Paul

RE: Getting VE MapControl to place maps by Zip Code by indiehead on 31 Oct 07 @ 10:52:00 UTC

excellent work!!!

linked it to my site, really helped me out a lot.

Well done!

http://www.red91.com

RE: Getting VE MapControl to place maps by Zip Code by aprompt on 12 Aug 08 @ 09:36:00 UTC

Hi,

This is just the thing I've been looking for, however I'm in the UK and need to use UK addresses and postcodes.

I've tried several options but the map doesn't regonise the addresses and throws up an error - no results found (but does add 4 markers (the amount of records in my xml file) at random places in the world.

Here's a typical entry for a UK address:

<event>

<image>NoPhoto.gif</image>

<emailA>john@email.eml</emailA>

<date>b-Day:04/18</date>

<P2LMname>Mircosoft</P2LMname>

<location>Microsoft Campus</location>

<cityst>Reading Berkshire</cityst>

<zip>RG6 1WG</zip>

<phone>0870 60 10 100</phone>

</event>

Can anyone help?

Thanks.

Reply

Not signed in. Sign in or sign up?