wiki:MapGuideRfc72

MapGuide RFC 72 - Commercial Map Service Support

This page contains an change request (RFC) for the MapGuide Open Source project. More MapGuide RFCs can be found on the RFCs page.

Status

RFC Template Version(1.0)
Submission Date(Date/Time submitted)
Last Modified Arthur Liu Timestamp
AuthorArthur Liu
RFC Statusretracted/rejected (implemented in Fusion instead)
Implementation Statuspending
Proposed Milestone2.2
Assigned PSC guide(s)Tom Fukushima
Voting History(vote date)
+1
+0
-0
-1
no vote

Overview

Commercial tiled map layers can be used as basemaps within MapGuide flexible layouts. Users can use MapGuide overlays with commercial map service layers(Google maps, Yahoo maps and Bing maps).

Motivation

Fusion provide a solution to integrate the commercial map services into the standard template:

  1. Add some script tags to index.html. These scripts indicate commercial mapping api providers and unique api keys supplied by these providers.
  1. Modify the application definition to include the commercial map service layers.

[Detailed Information] http://trac.osgeo.org/fusion/wiki/MapGuideCommercialOverlays

MapGuide templates should also have the capability to support the commercial map services. But it's not proper to add all the commercial api script tags into MapGuide templates by default because of script loading time. We need to provide a more convenient approach to add these scripts.

Proposed Solution

  1. Save the commercial mapping api scripts and keys in the extension part of application definition.
  1. MapGuide templates load the extension information from the application definition , and add the script tags into index.html on demand.

So users just need to provide an application definition with the extension, then they will obtain the commercial mapping services.

To load scripts from the application definition, MapGuide template file need to add a script like

    <script type="text/javascript">
        // Add script elemtent
        var addElement = function(element) {
            if (!element) {
                return;
            }
            var src = element.textContent; 

            // For IE Browser
            if (!src) {
                src = element.text;
            }

            var e = document.createElement("script");
            e.src = src;
            e.type = "text/javascript";
     
            document.getElementsByTagName("head")[0].appendChild(e);
        }
        
        //  Get ApplicationDefinition
        var appDefUrl = Fusion.getQueryParam('ApplicationDefinition');
        var xhr = new XMLHttpRequest();

        xhr.open("GET", [MapAgentUrl]?OPERATION=GETRESOURCECONTENT&VERSION=1.0.0&LOCALE=en&CLIENTAGENT=MapGuide+Developer&RESOURCEID=" + appDefUrl + "&FORMAT=text%2Fxml", false);
        xhr.send(null); 
        var appDefXML = xhr.responseXML.documentElement;

        // Get Google element
        var googleElement = appDefXML.getElementsByTagName("Google")[0];
        addElement(googleElement);

        // Get Yahoo element
        var yahooElement = appDefXML.getElementsByTagName("Yahoo")[0];
        addElement(yahooElement);

        // Get Virtual Earth element
        var veElement = appDefXML.getElementsByTagName("VirtualEarth")[0];
        addElement(veElement);

        // If there's no commercial layers, then register the onload event immediately. 
        if(!googleElement && !yahooElement && !veElement) {
            window.onload = init;
        }
        else{
            //Lazy load if there's any commercial layers
        }
    </script>

The original Window.onload event will be replaced by init function which will be called on demand.

  • To get the mapAgentUrl, we can just reuse some code in Fusion
  • For the lazy loading commercial API scripts, we also need to provide a method to verify if all the needed scripts have been loaded. Then to intitialize the Fusion.

Implications

Existed MapGuide templates(aqua, limegold, maroon, slate and turquoiseyellow) need to be updated to support load commercial api from application definition.

Test Plan

Test 5 MapGuide templates(aqua, limegold, maroon, slate and turquoiseyellow) to verify if they could support the commercial map services.

Funding/Resources

Supplied by Autodesk.

Last modified 15 years ago Last modified on 02/05/10 12:14:36
Note: See TracWiki for help on using the wiki.