0

Gmaps4rails에서 생성 한지도를 현지화하고 싶습니다. 사용자가 원하는 언어로 장소 이름을 표시 할 수 있습니다. Google은 여기에 문서를 작성하는 방법을 설명합니다. https://developers.google.com/maps/documentation/javascript/examples/map-languageGmaps4rails -지도 언어 설정 방법

GMaps4rails의 표준 (현재 기능적) 구현을 사용하고 있습니다. 여기에서 볼 수 있습니다. HTML로 렌더링

handler = Gmaps.build('Google'); 
handler.buildMap({ 
    provider: { styles: mapStyle }, 
    internal: {id: 'map'} 
}, function(){ 
    markers = handler.addMarkers(<%=raw @hash.to_json %>); 
    handler.bounds.extendWith(markers); 
    handler.fitMapToBounds(); 
}); 

...

<div class="map-container"> 
    <div id="map"></div> 
</div> 

난 그냥 언어 코드를 정의 할 곳을 찾아야합니다. 기꺼이하지 않고 제공자에게 옵션으로 추가하려고했습니다 (예 : provider: { styles: mapStyle, language: 'zh-TW' }).

문서 (및 출처)를 샅샅이 조사했지만 이에 대한 정보를 찾을 수 없습니다. 어떤 도움을 주시면 감사하겠습니다!

답변

0

스크립트에 언어를 지정해야합니다. Maps API v3 Now Speaks Your Language 예를 들어

: 당신은 여기 languages의 목록을 찾을 수 있습니다

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=pt-BR"> 

.

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Localizing the Map</title> 
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> 
    <meta charset="utf-8"> 
    <style> 
     html, body { 
     height: 100%; 
     margin: 0; 
     padding: 0; 
     } 
     #map { 
     height: 100%; 
     } 
    </style> 
    </head> 
    <body> 
    <div id="map"></div> 
    <script> 
     // This example displays a map with the language and region set 
     // to Japan. These settings are specified in the HTML script element 
     // when loading the Google Maps JavaScript API. 
     // Setting the language shows the map in the language of your choice. 
     // Setting the region biases the geocoding results to that region. 
     function initMap() { 
     var map = new google.maps.Map(document.getElementById('map'), { 
      zoom: 8, 
      center: {lat: 35.717, lng: 139.731} 
     }); 
     } 
    </script> 
    <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap&language=ja&region=JP" 
    async defer> 
    </script> 
    </body> 
</html> 

이 코드 라인에서 볼 수 있듯이, language=ja&region=JPkey=YOUR_API_KEY&callback=initMap&은, 언어가 JP = 일본어로 설정 : 여기

는 코드 샘플입니다.

sample의 동적 언어 설정을 확인하십시오.

희망이 도움이됩니다.

+1

감사합니다. Mr.Rebot, 저는 보석을 통해 이것을 처리 할 수있는 방법이있을 것이라고 생각했지만, 레일에서 src를 동적으로 편집 할 수있는 방법이 있습니다. 귀하의 게시물을 가져 주셔서 감사합니다. – vaughanos