Changes between Version 2 and Version 3 of MapGuideRfc72


Ignore:
Timestamp:
Jul 30, 2009, 2:46:07 AM (15 years ago)
Author:
liuar
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MapGuideRfc72

    v2 v3  
    2222== Overview ==
    2323
    24 Commercial tiled map layers can be used as base layers within MapGuide flexible layouts. Users can use MapGuide overlays with commercial map service layers(Google maps, Yahoo maps and Virtual Earth).
     24Commercial 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).
    2525
    2626== Motivation ==
    2727
    28 Fusion provide a solution to integrate the commercial map services into standard template: [[BR]]
     28Fusion provide a solution to integrate the commercial map services into the standard template: [[BR]]
    2929
    30 1. Add some script tags to index.html manually. These scripts indicate commercial mapping api providers and unique api keys supplied by these providers.[[BR]]
     301. Add some script tags to index.html. These scripts indicate commercial mapping api providers and unique api keys supplied by these providers.[[BR]]
    3131
    32322. Modify the application definition to include the commercial map service layers. [[BR]]
    3333
     34[Detailed Information] http://trac.osgeo.org/fusion/wiki/MapGuideCommercialOverlays
    3435
    35 MapGuide templates should have the capability to support the commercial map services too, and we also need to provide a more convenient approach to add scripts.
     36MapGuide templates should have the capability to support the commercial map services too. But it's not proper to add all the commercial api script tags into MapGuide templates by default. We need to provide a more convenient approach to add these scripts.
    3637
    3738== Proposed Solution ==
    3839
    39 1. Save the commercial mapping api providers and keys as extension in application definition.[[BR]]
     401. Save the commercial mapping api scripts and keys in the extension part of application definition.[[BR]]
    4041
    41422. MapGuide templates load the extension information from the application definition , and add the script tags into index.html on demand. [[BR]]
    4243
    43 So users just need to provide an application definition with extension, then they will obtain the commercial mapping services.
     44So users just need to provide an application definition with the extension, then they will obtain the commercial mapping services.
     45
     46To load scripts from the application definition, MapGuide template file need to add a script like
     47
     48{{{
     49    <script type="text/javascript">
     50        // Add script elemtent
     51        var addElement = function(element) {
     52            if (!element) {
     53                return;
     54            }
     55            var src = element.textContent;
     56
     57            // For IE Browser
     58            if (!src) {
     59                src = element.text;
     60            }
     61
     62            var e = document.createElement("script");
     63            e.src = src;
     64            e.type = "text/javascript";
     65     
     66            document.getElementsByTagName("head")[0].appendChild(e);
     67        }
     68       
     69        //  Get ApplicationDefinition
     70        var appDefUrl = Fusion.getQueryParam('ApplicationDefinition');
     71        var xhr = new XMLHttpRequest();
     72
     73        xhr.open("GET", "http://127.0.0.1/mapguide2010/mapagent/mapagent.fcgi?OPERATION=GETRESOURCECONTENT&VERSION=1.0.0&LOCALE=en&CLIENTAGENT=MapGuide+Developer&RESOURCEID=" + appDefUrl + "&FORMAT=text%2Fxml", false);
     74        xhr.send(null);
     75        var appDefXML = xhr.responseXML.documentElement;
     76
     77        // Get Google element
     78        var googleElement = appDefXML.getElementsByTagName("Google")[0];
     79        addElement(googleElement);
     80
     81        // Get Yahoo element
     82        var yahooElement = appDefXML.getElementsByTagName("Yahoo")[0];
     83        addElement(yahooElement);
     84
     85        // Get Virtual Earth element
     86        var veElement = appDefXML.getElementsByTagName("VirtualEarth")[0];
     87        addElement(veElement);
     88
     89        // If there's no commercial layers, then register the onload event immediately. (Lazy load if there's any commercial layers)
     90        if(!googleElement && !yahooElement && !veElement) {
     91            window.onload = init;
     92        }
     93    </script>
     94}}}
     95
     96The original Window.onload event will be replaced by init function which will be called on demand.
    4497
    4598== Implications ==
    4699
    47 Just add a script tag into index.html of MapGuide templates, which used for loading extension information from application definition. [[BR]]
    48 For those application definitions which do not have extenstion information, there's no additional burden.
     100Existed MapGuide templates(aqua, limegold, maroon, slate and turquoiseyellow) need to be updated to support load commercial api from application definition.
    49101
    50102== Test Plan ==