This example demonstrates how to implement an interview extension that uses a map as an input type to provide an address location. This is done using a control that geo-locates the current user, displays a pin on the map and shows the latitude and longitude of that location.
This functionality can be used in an interview when, for example, the user needs to report the location of an incident which may not be the exact location of the user, and may not be a street address (for instance, in park land).
This example uses the Google Maps Platform in order to display a Google map in an interview screen. In your Google Cloud Console, you will need:
This example only requires 3 attributes to be created in your project in Oracle Policy Modeling:
There are 2 custom files that we need for our implementation that can be downloaded in this ZIP. The 2 files are:
Copy these 2 files into the /interview-theme/resources folder for your project. (This folder is created when you click the Custom Files button in the Styles dialog box on the Interview tab in Policy Modeling.)
In our example, we are going to assume that the user wants to identify a location in their vicinity and therefore start the map centered on their location. For this reason, we are going to add a start screen that captures the user's location. This screen is set to always show.
Be aware that when the user's location is automatically detected in this way, if the user is using the interview in a web browser, the location will be roughly determined by the geo-location data associated with their IP address. If the user is using a mobile interview, the phone's GPS will be able to accurately determine the latitude and longitude of their address.
Pro Tip! If you don't want to automatically detect the user's location, you can hard-code the latitude and longitude for the center of the map in the JavaScript interview extension file.
In our example, we are going to have a second interview screen that:
Let's start with the Google map. You need to:
Pro Tip! The values for these properties could instead be specified in the interview extension JavaScript file. They are implemented this way in our example to make it easy to adjust these settings from within Policy Modeling.
Now, let's add some fields for the display of the specified location:
To test the customization you will need to run the interview in a browser either by using Ctrl+F5 from Policy Modeling or by launching the interview from Intelligent Advisor Hub.
In your browser, the interview should begin with the screen which is (indirectly) capturing the user's location.
On the Map screen which is displayed next, you will notice that the map starts out with a pin in the center of the map showing your location. The latitude and longitude of this location are displayed below the map.
You can then use your mouse to pinpoint another location on the map (the location of the incident). This position on the map is automatically converted into an address that is displayed in the 'Incident address' field below the map. The latitude and longitude shown are also updated to show the coordinates of the identified location.
If you would like further information on any of the concepts covered in this example, please visit these topics in the Intelligent Advisor Documentation Library:
For further information on the Google Maps Platform, see: https://cloud.google.com/maps-platform
Walkthrough design and implementation by Robert Surujbhan (Oracle)
Many thanks to Magia Solutions for reviewing this post.