In the Virtual Earth AJAX control, there are certain screens that are somewhat hard to capture and control. We pride ourselves on the level of control we give our users, so here’s a little tidbit to hopefully help you retain what hair is left atop your head. I posted an entry a while back called Geocoding with Virtual Earth that should get you this far; but, what should you do when you get a box like this and you don’t want your users to see it?
The crux of the issue is using the “what” and “where” properties together in the VEMap.Find() method. When you do this, you’re actually using a different geocoding engine than you would be if you were to leave the “what” field blank using the same VEMap.Find() method.
So, how do you work around this?
- You could do two calls – one for geocoding using VEMap.Find() and another for the “what” and “where,” but only extract the “what” results. This will use the new geocoding engine and won’t show these messages.
- Set the ShowMessageBox property on the map to false before making the what/where Find call. This property is not documented (thus, not totally tested); however, it’s a simple property that just prevents message boxes from being displayed in the control.
So, your code would look something like this (for solution 2):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0014)about:internet -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
var map = null;
map = new VEMap('myMap');
map.ShowMessageBox = false;
<div id='myMap' style="position:relative; width:800px; height:600px;"></div>
<INPUT id="txtWhere" type="text" name="txtWhere">
<INPUT id="find" type="button" value="Find" name="find" onclick="FindLoc();">
Now, the thing to remember is that you’re suppressing the error so the exciting thing that happens is….nothing! But, hey, that’s what you want! You want control? You got it. Just make sure that if you suppress the error you throw one up of your own otherwise your users may sit and blankly stare at your map waiting for something to happen.