2017-08-24 62 views
0

我有一個spring/dojo應用程序。要求是在地圖中找到一個地址在stackcontainer/content-pane中。首先想到的是將重定向到谷歌地圖和CORS & ACCESS_ORIGIN問題正在被拋出。如何在dojo內容窗格中呈現Google地圖

任何人都可以指導我們嗎?

回答

0

不知道你的意思是「重定向到谷歌地圖」,我不熟悉春天。

下面是我在一些Google搜索(其中包括here)之後構建的一個示例,它使用google maps javascript api,並在ContentPane中顯示地圖(至少在我的環境中)。您需要提供您的谷歌API密鑰和適應配置您的環境:

<!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> 

它在gmapLoader,被描述here(下名字async.js)的依賴。

jc