In addition to styled maps #2734643: Support Google Styled Maps (via Google API), I want to be able to customise the markers on my map. The attached patch adds this functionality.

It's not as fully featured as I would like. For now it provides a setting where a user can enter the absolute url to a marker icon. Ideally this wouldn't have to be absolute or could be uploaded or could come from each row configuration so different result rows could have different markers - this would be nice to allow the icon vary by content type for example. However, this is a first draft of it.

Comments

stella created an issue. See original summary.

stella’s picture

derjochenmeyer’s picture

Status: Needs review » Needs work

Patch does not apply anymore after last commit.

stella’s picture

Status: Needs work » Needs review
StatusFileSize
new10 KB

Attached is a re-rolled patch against latest HEAD. There are some changes in this patch however:

First, for the recently committed map control configuration bits - I moved the rendering of them above the handling of the 'center' setting, as that section can return prematurely in some cases, causing the following code (which sets the map control visibility settings) not to be executed. This was affecting my icon settings too, so fixed it for both here.

Secondly, I changed how this patch worked. There is now a textfield in the style settings where you can configure an absolute url to a marker icon as before. This is the default marker. There is also a drop-down matching fields in the view of type 'file_uri'. This means users can add a file uri field to their view (might be an icon stored on a node, or on an associated taxonomy term as in my case) and that icon uri will be used instead of the default marker.

FYI, to add an image uri to the view (cos this took me some time to figure out):

1. Create your content type with an image field and location field.
2. Create your geolocation view, with title and geolocation as fields on the view as normal.
3. Add a relationship to the view on the image field for your content type.
4. You will then see a new 'File' group when you go to add a field - and there you should be able to add a 'File: URI' field and set the Relationship drop-down to the relationship you've just added.
5. Edit the style settings and configure the file uri field for the 'Marker icon field' drop-down there.
6. Save and clear cache if necessary.

If some rows do not have an icon uri returned (e.g. no image attached to the node), then the default marker will be used. If the default marker field is left empty, then Google's default red pin marker is used.

It'd be nice as a further extension to be able to configure different markers for different content types, but I'm not sure how to approach that just yet and this is a good first step.

stella’s picture

StatusFileSize
new16.37 KB

Ok, one last version of the patch. I figured after allowing users to customise the markers used per result row, it might be nice to display a legend if needed.

To do this I followed the Google Maps API guide at https://developers.google.com/maps/documentation/javascript/tutorials/ad... and then added some more settings to the style. There's a checkbox to enable display of a legend, along with settings to position it and specify a 'string' field from the view fields to use as the legend text. The legend appearing is dependent on there being an icon field set, as it doesn't make sense otherwise.

screon’s picture

Just like support for styled maps, I need this one as well. I'll try it out and post back my findings.

screon’s picture

The patch applied, but I can't get the icons working. The images appear to be broken becasue the src attribute points to "public://...". When I change this in my browser to a relative path ("sites/default/files/..."), the icons appear.

Do you encounter the same problem?

stella’s picture

@screon there is a checkbox in the "File: URI" field called "Display the file download URI". That needs to be enabled too to get the absolute url. Sorry, forgot that bit.

The last submitted patch, geolocation_views_marker_icon.patch, failed testing.

The last submitted patch, geolocation_views_marker_icon.patch, failed testing.

The last submitted patch, geolocation_views_marker_icon.patch, failed testing.

The last submitted patch, geolocation_views_marker_icon.patch, failed testing.

The last submitted patch, geolocation_views_marker_icon.patch, failed testing.

The last submitted patch, 4: 2735061-4-views_marker_icon.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 5: 2735061-5-views_marker_icon.patch, failed testing.

a.sinitsa’s picture

Hi!
Patch does not apply to latest dev

christianadamski’s picture

@stella I highly appreciate this approach. Let the user select an image field for the icon. This way, a taxonomy could be pulled in well. Maybe add a selection for the image-style as well.

However: all the google map settings are outdated and need to be removed.

christianadamski’s picture

Status: Needs work » Needs review
StatusFileSize
new6.46 KB

- select any image field as icon
- image style will be used
- unrelated: made geolocation field #required
- unrelated: added "none" option to title field

  • ChristianAdamski authored 39cffff on 8.x-1.x
    Issue #2735061 by stella, ChristianAdamski: Allow customisable marker...
christianadamski’s picture

Status: Needs review » Fixed
a.sinitsa’s picture

Hi! Thank You!
But what if I need to use not image field?
For example: I need the map with users. Different user roles should have different icons. In views I create field with role id, overwrite it to output like image:
<img scr="/images/icons/role-icon-[role id].jpg" />
and wanted to use this as icon in map.

christianadamski’s picture

Hey,

how would you like this to work? Create a new issue as feature request.
Ideally you could use some kind of taxonomy with an image field, but I also have no idea how to do in this context.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.