Google Maps Integration
arcplan can integrate with any 3rd party tool that can communicate via JavaScript, one example of this is using Google Maps API to view geographically relevant data. An example of this can seen here, on our demo server. If you click the View in Google Maps button a map object is layered over the arcplan applet with data from arcplan. The arcplan application takes the data and builds KML to load into the Google map. The map object parses the KML file and overlays the polygon objects onto the map. Each polygon (or in some cases, a few polygons) makes up a state, and can have data associated with it. Clicking a state displays a popup containing information relevant to that state. This demo application only loads a table containing data values, but the popup can render any valid HTML so this could be customized to display anything. It should be noted, however, that any private (not available to the public) application that uses Google Maps must purchase the proper licensing from Google Inc. More information on this subject can be found on their Google Maps Premier site.
Polygons
In order to create an application like this, polygon KML data is required to define the overlay shapes. In this case, the KML was taken from publicly hosted code from Google. But if a custom map is needed, someone would have to build or buy the polygon mappings. This polygon information was then added in a table (in an arcplan internal database) along with the corresponding state name. A second table was created containing the state names and their corresponding data values. Since not every state has data values, the ones that do had to be matched up with the polygon data describing that state.
The top left object is a column containing all of the states with polygon information. The row object next to it contains measure names from the internal database and is used to find the data values for each state. The next column contains the KML for each state, followed by a column containing the selected measure. This measure is used to determine if a state is above or below a certain threshold and what color to fill the overlay with. The table on the top right shows the data values in a form that can be embedded into the KML. For each value, it must be wrapped in a Data element in the following format.
<Data name='MeasureName'> <value>SomeNumber</value> </Data>
Notice that this is only done for states that have data values. The column object on the bottom left uses the ColumnsToText() formula to concatenate all of the formatted data values into a single line. The KML Style Definition column determines the style of the state. It looks at the Selected Measure column and determines if it is higher, lower, or in between the user defined thresholds and displays "#HighData", "#LowData", or "#MiddleData". If there is no data for that state, it returns "#NoData" instead. This tag gets used by Google Maps to render the style of each state. The Placemark Element Column combines all of the state specific information into a single element, to be placed in the KML. The format for Placement elements is as follows.
For states that have no data values, just leave out the Extended Data element. The KML Header is a text object that contains the following header.
This header mostly contains the style information referenced in the Style Definition column. Here, those tags are defined to make the states a specific color and transparency. The color values are Hex codes in the order Alpha (7F), Blue (00), Green (AA), and Red (FF) to make 7F00AAFF. Last, the KML header is concatenated with a ColumnsToText() of the Placemark elements and the closing tags ("</Document></KML>").
Sending to Google Maps
Now that we have the complete KML, we need to make it available for Google Maps to download. There is an export button that exports the KML into a file in the web server directory located at C:\inetpub\wwwroot\GoogleMaps\. The filename is always "SessionID-Date-Time.kml" in order to make each request unique. This level of uniqueness is required because users can make multiple requests in the same session on the same day. If a user switches a menu, such as the products filter, a new KML file is generated and must be loaded by Google.
Once the KML file has been generated and placed in the web server directory, some JavaScript code must be executed to build new map elements on the webpage. This JavaScript code is added to the HTML start page so no additional files are required. There are two JavaScript functions, ShowMap() and HideMap(), and some custom CSS styling. There is also an iframe and div element included in the HTML, which are used by the JavaScript to display the map. Just make sure to change the applet element to point to your server and application. The specific code is listed below.
- 5,834 views
- 0 previews
- 9 versions
- 5 comments
- 1 follower
- Updated By:
- Takashi Binns
- January 6, 2012
- Posted By:
- Takashi Binns
- January 6, 2012
- Versions:
- v.9
Page Options
5 Comments
Nice example!
i developed the application as u described in the eg. but whenever i click on the button 'showmap' this error comes : ' could not find .kml file' .
Gmap will automatically come when we click on the showmap button or any further calculations are needed?
As we given right path then why same error is showing every time i.e., could not find the path specified. plz help us.
I will just make a quick comment here that the KML method is no longer absolutely necessary. With the Google Maps API v3, you can generate your map from javascript JSON data via a secure channel with no need for Google to contact your server to download KML. I have built an example where arcplan just generates the necessary HTML and Javascript dynamically based on data in a database. The same concept is available for creating other types of google docs, so it is not limited to just maps.
It would be nice to see arcplan provide some wrappers for this sort of thing and to automatically generate some basic google documents directly from arcplan files. I'm sure that now this is entirely possible and relatively easy. When comparing a free Google solution with using a solution like Aspose to generate Microsoft files, it becomes very attractive.