Friday, June 25, 2010

Google Maps

What a mash!

Many of the comments on one of the more popular posts (Google Maps in Siebel CRM) on this blog and e-mails I received from readers are around the question:

How can we show multiple addresses in Google Maps?

There are two answers:

First, there is the Google Maps API, which allows you to do (almost) anything you want by using the documented JavaScript functions. However, implementing an embedded map in the Siebel CRM Web Client using the JavaScript API is still a challenge and requires a lot of (browser) scripting. If anyone has gone that far, please let us know.

The second answer - and subject of this post - is of much lower effort (it's scriptless). Of course we can not expect the full glory of interactive maps but maybe the following example holds something for you. At least you'll see how to use Multi-Value Fields with Symbolic URLs.

Besides the JavaScript API, Google has published a URL-based API for static maps. The only thing we have to do is generate a URL similar to the following (line breaks added for better readability):

http://maps.google.com/maps/api/staticmap?
size=650x350&
maptype=roadmap&
markers=Niagara+Falls&
markers=Vienna,Austria&
sensor=false

Click here to see the result of the URL (which is slightly modified from the above to impress you ;-)

The Google server returns a PNG graphic.

The parameters such as size, zoom, maptype and sensor are nicely explained (along with many other options) on the documentation page of the Google Static Maps API. What is of special interest for our requirement of showing multiple account locations is the markersparameter which obviously can be repeated multiple times and produces one marker icon per address.

The markers parameter takes at minimum an address string but can also take other input strings such as the icon graphic, the marker color and a (single character) label text.

How to use the Google Static Maps API with Symbolic URLs

The URL above has been generated by the Siebel Portal Framework. Similar to the well-known example of integrating the dynamic Google maps - which sadly support only a single address - we have to create a Symbolic URL as follows:

URL: http://maps.google.com/maps/api/staticmap
Fixup Name: Default
Multivalue Treatment: Separate Arguments

The Multivalue Treatment parameter is the key to success. When we specify Separate Arguments, then the Portal Framework will repeat the argument for each value of the multi-value field associated with the parameter.

Let's look at the arguments list for the Symbolic String (click to enlarge):

The hot record is the markers argument which takes the name of a (new) multi-value field which concatenates the city, state, zip code and country of an address to a comma-separated string.

The rest of the parameters is similar to our previous example on Google Maps integration. Please refer to this example also for details on how to create the applet etc.

As a result, a static image is returned with one marker for each address of the account.

Summary

With the Google Static Maps API it is possible to embed an image-based Google map in Siebel CRM showing all address locations for the selected account. The Siebel Portal Framework supports the generation of the same URL parameter for each value of a multi-value field, providing a low-effort solution.

Have a nice map

@lex

No comments: