0

我有一个 spring/dojo 应用程序。要求是在 map 中的 stackcontainer/content-pane 中找到一个地址。首先想到的是重定向到谷歌地图,并且正在抛出 CORS 和 ACCESS_ORIGIN 问题。

谁能指导我们?

4

1 回答 1

0

Not sure what you mean with "redirection to google maps", and I am not familiar with spring.

Below an example that I built after some googling (among others here), uses the google maps javascript api, and displays a map in a ContentPane (at least in my environment). You'll need to provide your google API key and adapt config to your environment:

<!DOCTYPE HTML>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Google maps demo</title>
    <link rel="stylesheet" href="dojo-release-1.12.2-src/dijit/themes/claro/claro.css" media="screen"> 
</head>
<body class="claro">
    <div id='theMap'></div>
    <script>var dojoConfig ={
                baseUrl: "", isDebug: true, async: true,
                packages: [{"name": "dojo", "location": "dojo-release-1.12.2-src/dojo"},   {"name": "dijit", "location": "dojo-release-1.12.2-src/dijit"},  
                ],
            };
    </script>
    <script src="dojo-release-1.12.2-src/dojo/dojo.js"></script>
    <script>
        require([
            'dijit/layout/ContentPane',
            'myApp/gmapsLoader!http://maps.google.com/maps/api/js?v3&key=YOUR_GOOGLE_API_KEY'
        ], function (ContentPane) {
            var theMap = new ContentPane({style: {height: '1000px'}}, 'theMap');
            var mapOptions = {
                    center : new google.maps.LatLng(-34.397, 150.644),
                    zoom : 8,
                    mapTypeId : google.maps.MapTypeId.ROADMAP
            };

            var theMapContent = new google.maps.Map(theMap.domNode, mapOptions);
            theMap.startup();
        });
    </script>
</body>
</html>

It has a dependency upon gmapLoader, which is described here (under the name async.js).

jc

于 2017-08-26T21:56:13.370 回答