Share via


Contact Map Code Sample

The Contact Map code sample is designed to show one way that you can use Windows SharePoint Services 3.0 Web services to create a mashup that extends the functionality of a Microsoft Office Live Small Business application. This mashup takes advantage of the Microsoft Virtual Earth platform, which is a mapping and location service.

The Contact Map sample, which uses Contact Manager, creates a map control that you can use to display the location of the work addresses of contacts from the Contact Manager Business Contacts list on a map provided by Virtual Earth.

Add the code sample as a solution

The Contact Map code sample is located in the MSDN Code Gallery.

The download file is a solution (.olp) file, which you can add to any Office Live Small Business account as a custom business application. To learn more about adding solutions to an account, see Add a Solution to an Office Live Small Business Account.

See the sample in action

  1. On the left navigation bar, click Business Applications.

  2. On the left navigation bar, click Map Contacts.

  3. In the library, click samplepage.

The Sample Web page opens, and a Page Viewer Web Part displays the Contact Map. The right side of this Web Part contains a check box for each contact in Contact Manager that specifies a work address. Select the check box next to each contact that you want to appear on the map, and a pushpin appears at the contact’s address.

How it Works

The files that contain the code used in this application are stored in the document library in the application. Several functions in the maps JScript (maps.jsx) file combine to make this mashup, including functions to set up a map, add contacts to the map, and remove contacts from a map.

Set up a map

The getMap function initializes a Virtual Earth Map (VEMap) object.

Get contacts

The getContacts function uses the Windows SharePoint Services 3.0 Web service to obtain the list of contacts from the specified context. In this sample, the context is Contact Manager. This code is a reference you can use to model calls to the Windows SharePoint Services Web services that are hosted by Office Live Small Business. These services give you access to the lists in Contact Manager, such as the Business Contacts list used in this example. You can read data from the list, insert, update, and delete records, and much more.

Note

If you downloaded this code sample before January 2008, the global variable CONTACTSLISTNAME may be set to 'Contacts'. You must change this variable to 'Business Contacts'.

Add and remove contacts on the map

When the Contact Map page is first loaded, this sample code retrieves the contacts that include address information by using Windows SharePoint Services 3.0 Web services. Each contact is cached as an object in the browser’s memory. When the addContactToMap function is called, the address information from the contact object of the selected contact is passed into the Virtual Earth API to add a pushpin on the map in the correct location. The fact that the contact has a Virtual Earth pushpin object is then cached into this contact object.

When you cancel the selection of a contact, the removeContactFromWeb function calls back to the Virtual Earth API and passes the object to remove the pushpin. The contact is passed to the removal function because an ID associated with each contact is passed as the ID of the pin.

Package the SOAP requests

To make this code sample work, the download also includes Microsoft JScript functions to package the SOAP requests that you use to communicate with Windows SharePoint Services Web services. You can use these same functions from the common JScript (olsharedlibv1.jsx) file to jump-start your development work.

See also

Windows SharePoint Services 3.0 Features Used in Office Live Small Business
Time Card Code Sample
Property Value Estimator Code Sample

Contact Manager