Вопрос

с gmaps4rails есть способ Определите пользовательский маркер .Но тот же тот же затем показан для каждой записи базы данных.

Как бы я показать другой маркер для каждой записи базы данных, как в Google широте?Предпочтительно через собственный столбец базы данных или через спрайт, если есть только картинки для категорий / групп, а не отдельных пользователей.

Это было полезно?

Решение

Building on apneadivings answer, two possibly shorter ways come to mind:

Generic:

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

In this case, we reuse the category column as the name for the picture:

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

The only thing missing now, is a way to use sprites. But thats probably impossible.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top