This project is read-only.

Getting Started in Web Services


There are many different approaches to loading data into the Bing Maps Ajax API, some of which are never recommend (creating dynamic javascript code on the server side) and others which make sense in different situations. One of the most scalable, flexible and powerful is loading your maps data using web services via JSON (JavaScript Object Notation).

This sample application shows how easy it is to call a normal WCF web service from javascript using the MS Ajax Client Script Library as well as showing a best practice approach to writing Object Orientated javascript (again using the MS Ajax Library) to load the map and handle map events.

We have tried to keep this sample as simple as possible, whilst still producing code suitable for production usage.

What exactly does the sample do?

The sample is now complete and shows how to load map data (of some schools in the UK) from an SQL 2008 database using a datalayer built using Entity Framework 4 (ORM). The datalayer is used by a WCF service which is called via javascript and returns JSON data for the map to display.

Getting Started

To get started with this sample you will need to have VS 2010 and SQL Express 2008 installed. Once you have those installed you can download the sample from the source code tab in the path " Samples/Getting Started in Web Services/WebserviceBingMaps"

What is simplified for the sample?

There are a few things that are simplified, or just not done, that should be before putting into production":

  1. The javascript files are not compressed at all, I recommend looking at for automating this
  2. The javascript files are not combined into one script, again look at chirpy to help with this
  3. The site is still set in debug
  4. The pushpins in the example overlap at higher zoom levels, you should look at clustering them (hopefully a future sample) if your data suffers from this to ensure performance and usability
  5. The infobox control is very simple, hopefully in time the community will create a better one if an official one doesn’t arrive soon
  6. GZip compression is not setup specifically in the web.config file as this is dependant on what version of IIS you install it on. Enabling GZip compression will mean the JSON data from the webservice will be compressed massively increasing your applications data transfer performance

Understanding the code

Hopefully, over the next few months there will be a set of tutorial blog posts created that will walk you through writing this application. Until then feel free to download and browse the code which is pretty well commented.

Last edited Dec 28, 2010 at 4:53 PM by earthware, version 8


No comments yet.