2015-12-13 24 views
0

嘛,我發現它在網絡上:如何改變lat和長PARAMS

<!doctype html> 
<html lang="en"> 
<head> 
<meta charset="UTF-8"> 
<title>Google Maps con Polymer</title> 

<link rel="stylesheet" href="css/google-map.css"> 

<script src="components/platform/platform.js"></script> 
<!-- 2.- La sentención (link rel="import") nos permite importar Web Components personalizdos 
     en este caso estamos importando el de google-map --> 
<link rel="import" href="components/google-map/google-map.html"> 

</head> 
<body> 

<google-map lat="37.790" long="122.390"></google-map> 


</body> 
</html> 

這表明我的舊金山,EEUU。但是,當我改變參數(拉特和長):

<google-map lat="-30.761" long="-57.990"></google-map> 

它顯示我相同的地圖。

我改變相同PARAMS在該文件中的谷歌組件:「搜索引擎map.html」

這是一段代碼:

<script> 

Polymer('google-map', { 

/** 
* A Maps API key. To obtain an API key, see developers.google.com/maps/documentation/javascript/tutorial#api_key. 
* 
* @property apiKey 
* @type string 
*/ 
apiKey: null, 

/** 
* A latitude to center the map on. 
* 
* @attribute latitude 
* @type number 
* @default 37.77493 
*/ 
latitude: -30.761111, 

/** 
* A longitude to center the map on. 
* 
* @attribute longitude 
* @type number 
* @default -122.41942 
*/ 
longitude: -57.990111, 

和它的功能爲我。

所以我需要解決這種情況:獲得我想要的地圖,但只有我在應用程序的主索引中調用的參數。不能觸摸或重寫組件代碼。

回答

0

屬性名稱應該是latitudelongitude

<google-map latitude="-30.761" longitude="-57.990"></google-map>

+0

謝謝,它真的功能! – user3780282

+0

很高興能幫到你!您可能想將此標記爲已接受的答案。 –

0

嘗試從Google Maps Tutorials page

<!DOCTYPE html> 
<html> 
    <head> 
    <style> 
     #map { 
     width: 500px; 
     height: 400px; 
     } 
    </style> 
    <script src="https://maps.googleapis.com/maps/api/js"></script> 
    <script> 
     function initialize() { 
     var mapCanvas = document.getElementById('map'); 
     var mapOptions = { 
      center: new google.maps.LatLng(-30.761, -57.990), 
      zoom: 14, 
      mapTypeId: google.maps.MapTypeId.ROADMAP 
     } 
     var map = new google.maps.Map(mapCanvas, mapOptions) 
     } 
     google.maps.event.addDomListener(window, 'load', initialize); 
    </script> 
    </head> 
    <body> 
    <div id="map"></div> 
    </body> 
</html> 

另外下面的代碼,你可以設置變焦(變焦:3-21)和禁用滾輪(滾輪:真/假)

+0

好的!感謝您的早期答案..但想法是使用Web組件...所以你可以創建地圖,無論你想多少次。 – user3780282