5

gmaps4rails으로가는 방법은 define a custom marker입니다. 그러나 각 데이터베이스 항목에 대해 동일한 항목이 표시됩니다.gmaps4rails을 사용하는 Google지도의 다른 마커

Google 위치 찾기와 같이 데이터베이스 항목별로 다른 마커를 어떻게 표시하나요? 자신의 데이터베이스 열 또는 스프라이트를 통해 바람직하게는 개별 사용자가 아닌 범주/그룹에 대한 그림 만있는 경우.

는 는 apneadivings 대답에

답변

4

건물, 두 가지 가능성이 짧은 가지 방법이 마음에 와서 :

def gmaps4rails_marker_picture 
    { 
    "picture" => "/images/" + self.category + ".png", 
    "width" => 32, #beware to resize your pictures properly 
    "height" => 32 #beware to resize your pictures properly 
    } 
end 
:

def gmaps4rails_marker_picture 
    { 
    "picture" => self.image_path, # image_path column has to contain something like '/assets/my_pic.jpg'. 
    "width" => 32, #beware to resize your pictures properly 
    "height" => 32 #beware to resize your pictures properly 
    } 
end 

이 경우, 우리는 그림의 이름으로 범주 열을 재사용 : 일반

지금 누락 된 유일한 것은 스프라이트를 사용하는 방법입니다. 그러나 그것은 불가능할 것입니다.

+1

잘 완료 jmk;) – apneadiving