2017-09-11 11 views
0

Google지도 웹 구성 요소를 사용하려고하는데 lat, longs 위치에 여러 마커를 추가하려고합니다. creating a google map with marker using web-component 마커를 여러 개 추가해 보았습니다. webcomponents : 여러 마커가 Google지도 웹 구성 요소에 추가되지 않음

<link rel="import" href="../../bower_components/polymer/polymer.html"> 
<link rel="import" href="../../bower_components/google-apis/google- 
    apis.html"> 
    <link rel="import" href="../../bower_components/google-map/google- 
    map.html"> 
    <dom-module id="map-view"> 
    <template> 
    <google-map map="{{map}}" disableDefaultUI fitToMarkers> 
     <template is="dom-repeat" items="{{marker}}"> 
      <google-map-marker map={{map}} latitude="{{item.latitudine}}" 
      longitude="{{item.longitudine}}"> 
      </google-map-marker> 
     </template> 
    </google-map> 
    </template> 
    <script> 
    Polymer({ 
    is:'map-view', 
    properties:{ 
    marker:{ 
    type:Array 
    } 
    }, 
    ready: function() { 
     this.marker = [ 
      {latitudine: '41.223596', longitudine: '16.296087'}, 
      {latitudine: '41.222450', longitudine: '16.291259'} 
     ]; 
    } 
    }); 
</script> 

</dom-module> 

를 추가 처리되지 않습니다와 나는 다른 사업부 내에서지도 뷰를 사용하고 있지만, 여러 개의 마커 no marker를 얻을 수 없습니다 수 있어요

사람이 webcomponents를 GoogleMap으로 여러 마커를 추가하는 방법을 jsfiddle 보일 수 있는가?

답변

2

위의 코드는 완벽하게 작동합니다. 미국의지도를보고 있으며 마커가 이탈리아를 가리 킵니다. 축소하고 유럽을 체크인하십시오. 당신이 당신의 마커 근처에 기본보기를 변경하려면

markers

, 당신은 또한 google-map 요소에 위도와 경도를 설정할 수 있습니다. <google-map map="{{map}}" latitude="41.223596" longitude="16.296087" disableDefaultUI fitToMarkers>처럼. 귀하가 제공 한 직위 중 하나를 사용하고 있습니다. 가장 가까운 위도와 경도를 사용할 수 있습니다.

+0

okk 내가 처음 보았을 때 Google지도 API를 사용하고 있지만 다른 위치로 확대/축소하고 싶지만 Google에 페이지가 새로 고침 될 때마다 Google에서 검색을 시도했습니다. -map.html 그리고 줌인 센터의 속성을 오버라이드하려고했는데 다른 특정 위도와 경도로 확대/축소 할 속성을 알려주시겠습니까 – shashank

+0

google-map 요소에서 위도와 경도를 설정할 수도 있습니다. ''와 같습니다. 귀하가 제공 한 직위 중 하나를 사용하고 있습니다. 가장 가까운 위도와 경도를 사용할 수 있습니다. – Ofisora

+0

나는 쉬운 길을 잘못 가고 있었다. – shashank