Bing Maps controls enhance property search experience

John L. Scott Real Estate has been partnering with Microsoft on mapping projects for nearly eight years. In fact, we were one of the first real estate companies to offer map-based home searching way back in 2003. With Neighborhood Wizard™, released in 2007, we became the first residential real estate company in the nation to utilize the Microsoft polygon drawing technology to allow consumers to draw the exact boundaries of their desired search. In 2009 we released JLSConnect™, a customized Silverlight-based tool that we’ve continued to develop for the past two years.


JLSConnect™ has come a long way, and we’re pleased with how the map search product now maximizes the benefits of the Bing Silverlight Map Control. While we’ve included a few screen shots of the product below, feel free to explore the product on our webpage to get a better look.

The combination of Microsoft Silverlight and Deep Zoom technologies, along with John L. Scott’s search technology, make the searching experience very smooth. With this update, customers can now specify all the same criteria they can on our AJAX-based map: property type, price range, beds and baths, etc. They can also filter their results to highlight upcoming open houses or pending and sold properties.

We’ve also made the product more powerful by adding the ability for customers to modify the shape of their search polygon. Customers can now add, move, and remove the points that make up their polygon, giving viewers unprecedented flexibility.

In addition to updating our JLSConnect™ to maximize the benefits of the Silverlight Map Control, we’ve also finished refactoring our AJAX-based interactive map search to use the new AJAX 7.0 Control. Due to the Control’s increased performance, we’ve been able to expand the maximum results to 500 properties.

And with the new seamless transitions between each map type, we now support polygons all the way down to Bird’s eye.

These are only a few of the updates we’ve made to our search tools. Please stop by JohnLScott.com to see how we took full advantage of the Silverlight and AJAX 7.0 controls.


Bing Maps v7 control -New Version

It seems that, in the last few hours, Microsoft have pushed out a new release of the Bing Maps AJAX control (or, maybe their content delivery network has only just started serving a new version – the timestamp attached to the library URL, http://ecn.dev.virtualearth.net/mapcontrol/v7.0/js/bin/7.0.20110426171249.81/en-us/veapicore.js, suggests that it may have been compiled 10 days ago, on 26th April 2011).

This is a minor release – it’s not version 7.1 – so you wouldn’t normally expect to see much in the way of new features. However, it is significant since it appears to resolve a fairly crippling bug that previously made the map control unusable if instantiated in a container of the page that was not visible on initial load (i.e. if you wanted your map to be absolutely positioned in a div near the bottom of a long page that required the user to scroll to get to it).

There is also at least one change made to the default behaviour of the map, in that panning now exhibits an inertia effect – the map does not abruptly stop when you release the mouse button after panning, but slides to a gradual standstill. This change follows the trend of a lot of previous enhancements to v7, in making the AJAX control behave more like its Silverlight cousin (which has always had optional inertia).

You don’t need to do anything to use the new version – any requests to the v7 library will automatically retrieve the latest version, as follows:

[php]<script src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0" type="text/javascript"><!–mce:0–></script>[/php]

Of course, you might not want to use the new inertia effect. A quick dig around the code reveals that there is now a useInertia boolean property that can be passed in the mapOptions of the map constructor. To disable the inertia effect, create your map as follows:

map = new Microsoft.Maps.Map(
  document.getElementById("divMap"),
  {
    credentials: "ENTER YOUR KEY",
    center: new Microsoft.Maps.Location(54, -2),
    zoom: 4,
    mapTypeId: Microsoft.Maps.MapTypeId.road,
    useInertia: false
  }
);

You can also change the intensity of the inertial effect by setting the inertialIntensity property. If you want to make yourself dizzy, try the following and then give the map a give flick!

map = new Microsoft.Maps.Map(
  document.getElementById("divMap"),
  {
    credentials: "ENTER YOUR KEY",
    center: new Microsoft.Maps.Location(54, -2),
    zoom: 4,
    mapTypeId: Microsoft.Maps.MapTypeId.road,
    useInertia: true,
    inertiaIntensity: 1
  }
);

It’s almost impossible to make a side-by-side comparison of any other changes that occur between versions – the source code of the control is obfuscated, causing functions and parameters to be renamed with random letters between versions, so z = new function(cB, a) might be exactly the same as A = new function(h, t), but without comparing line-by-line you can’t be certain.

However, a quick examination of the new library does reveal some other interesting things to note:

  • New touch events: “touchstart“, “touchmove“, “touchend“, and “touchcancel
  • New classes: Microsoft.Maps.Streetside and Microsoft.Maps.VenueMaps

Of course, you can’t necessarily infer too much based only on the name of a class in the library but, even if these features aren’t exposed yet, it’s interesting to see what might be coming just round the corner…

Open Street Map and ESRI tiles on Bing Maps

In a previous post, I explained how to replace the base tile layer in the Bing Maps Silverlight control with an ESRI tile layer. In this post, I’ll show how to do the same but using the Bing Maps AJAX v7 control. You can use this technique to use the Bing Maps AJAX control, but replace the Bing imagery with OSM tiles or the ESRI tile layers used in the previous Silverlight post, as well as many other tile sources.

The first step is to specify not to load the default Bing Maps tile layer. Do this by specifying the mercator MapTypeId in the options passed to the constructor when you first initialise the map:

[php]mapTypeId: Microsoft.Maps.MapTypeId.mercator[/php]

The next step is to create a new TileSource. The uriConstructor of the TileSource must return the correct URI for a requested tile. If your tile provider names its tiles according to the default Bing Maps quadkey numbering system, then the uriConstructor can be a simple string using the {quadkey} placeholder. This will be replaced with the appropriate quadkey when the tile is requested:

[php]var tileSource = new Microsoft.Maps.TileSource(
{  uriConstructor: ‘http://www.microsoft.com/maps/isdk/ajax/layers/lidar/{quadkey}.png’ }
);[/php]

However, for OSM tiles, or any other tile providers that not follow the basic quadkey numbering system, we instead need a function to construct the appropriate URI for each tile. I’ll do this in a function called getTilePath, and I’ll specify this in the TileSource uriConstructor as follows:

[php]var tileSource = new Microsoft.Maps.TileSource({ uriConstructor: getTilePath });[/php]

The getTilePath function will return a string with the appropriate URI for the requested tile. For OSM tiles, a typical tile looks like http://tile.openstreetmap.org/zoom/x/y.png. The function to create this tile is therefore:

[php]function getTilePath(tile) {
return &quot;http://tile.openstreetmap.org/&quot; + tile.levelOfDetail + &quot;/&quot; + tile.x + &quot;/&quot; + tile.y + &quot;.png&quot;;
}[/php]

Put this all together and your code should look like this:

[php]&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html&amp;nbsp; xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;title&gt;&lt;/title&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function GetMap() {
// Create a basic map
var map = new Microsoft.Maps.Map(document.getElementById(&quot;mapDiv&quot;),
{ credentials: &quot;YOURBINGMAPSKEYHERE&quot;,
center: new Microsoft.Maps.Location(56, 2),
zoom: 5,
// Don’t load the Bing base map tiles
mapTypeId: Microsoft.Maps.MapTypeId.mercator
});

// Create the tile source
var tileSource = new Microsoft.Maps.TileSource({ uriConstructor: getTilePath });

// Construct the layer using the tile source
var tilelayer = new Microsoft.Maps.TileLayer({ mercator: tileSource, opacity: 1 });

// Push the tile layer to the map
map.entities.push(tilelayer);
}

function getTilePath(tile) {
// Construct the URI path for an OSM tile based on tile zoom/x/y
return &quot;http://tile.openstreetmap.org/&quot; + tile.levelOfDetail + &quot;/&quot; + tile.x + &quot;/&quot; + tile.y + &quot;.png&quot;;
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;GetMap();&quot;&gt;
&lt;div id=’mapDiv’ style=&quot;position:relative; width:640px; height:480px;&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;[/php]


And here’s what it looks like:

image

If you want to try some other tile providers, replace the URI constructed by the getTilePath() function with some of the following:

DeLorme World Basemap

[php]function getTilePath(tile) {
return &quot;http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer/tile/&quot;
+ tile.levelOfDetail + &quot;/&quot; + tile.y + &quot;/&quot; + tile.x;
}[/php]

image

ESRI World Imagery

[php]function getTilePath(tile) {
return &quot;http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/&quot;
+ tile.levelOfDetail + &quot;/&quot; + tile.y + &quot;/&quot; + tile.x;
}[/php]

image