Create a Link to Map an Address
Ever wanted to create a link in a SharePoint contact list or InfoPath form to click to view a map of a certain address? This technique is so simple, it will blow your mind! There are other ways, which entail embedding images, using REST web services and other custom code, but this one simply opens that address in the browser in a Bing map.
This can be done in SharePoint 2007, 2010, and in Office 365.
I’ll show you two ways to go about it. In both of these cases, I’ll assume you already have created fields for Street Address, City, State, and Zip code.
In InfoPath, here are the basics:
- Create a new field, and call it Map.
- Double click the name of the Map field to open its properties.
- Next to the Default value box, click the function button.
- Create a concatenation formula. We’re going to string together (concatenate) all of the address fields, into a specific URL.
concat(“http://www.bing.com/maps/?q=”, (LocationAddress, “%2C%20”, LocationCity, “%2C%20”, LocationState, “%20%20”, LocationZip, “&FORM=Z9FD”)
- Click OK.
- The default value will now look something like this, and be sure to leave the box checked so that the formula will always be refreshed.
- Click OK.
- Insert a cute little image into your form, something that looks like a map or globe or something.
- Click to select that image, and then on the Insert tab, choose Hyperlink.
- Click to select a Data Source for the Link To, and choose that Map field that you created earlier. Click OK.
- Done! Publish the form, and when you open the form and click the little map button, the browser will open to the Bing map of that location.
In SharePoint Designer, a form
- In SharePoint Designer, click the name of your list or library. In this example, it’s the out of box contacts list. In the Forms section on the right, click New, and create a new display form.
- Call it CustomDisplay, and set it as the default form.
(For the SharePoint 2007 method, Customize Form Pages in SharePoint (Video))
- Open this new form, and put the cursor in the Notes field, which is the last row of the table. Click the TAB key so that a new row is created at the end.
- Type “Map It” in the left cell, and in the right cell, insert that same graphic of something mappy.
- Click to select the image that you just inserted. It doesn’t have to be an image, you can just put a regular hyperlink in here. On the Insert tab in the ribbon, click Hyperlink.
- Paste the URL in the address box, and click OK:
- Save the page, and close SharePoint Designer. Open your contacts list in the browser, and open one of the contacts that has a real address in it. Click the icon you created, which will open the map!
Technorati Tags: SharePoint,Office 365,data view web parts,maps,mapping,InfoPath,map link
Hi Laura, I’m loving this little idea! Thanks for sharing. Do you know if Bing has a list of acceptable parameters, or is passing in location details with ‘commar space’ all that is required? When I made the ‘Map’ data into a hyperlink column to allow list view of submitted items, it fails if data was entered into Location Address with a space. I’m guessing I could place some formula onto the Location Address field in the form to output spaces as %20?
Hi Laura, I am an avid follower of your writings. This article sparked some interest because I have a requirement on an IP SOAP form to calculate mileage. Do yoju think if we have the source and target locations we could get the total mileage from the map details?
Hi Laura, Great post, but . . . . is it also possible to do without Infopath of Sharepoint Designer?
@Ron, I have never tried this but just thinking about it, if you used a calculated column and built the hyperlink in there based on the other fields using the same url above I would imagine you would have the same outcome. @Larry, I am not sure of Bings mapping api, but I have done similar workings for our own mileage calculator using Google’s map api. The only problem with google’s is you have to create an api account and have the text file it will generate for authentication available on your farm. @Laura, Great post, simplistic and very functional as always!
Thanks guys, glad you like it! Sure, this could probably be done in a calculated column, although I haven’t tried it.