UPDATE: I've posted a patch below, which allows for setting the scale value in a markers.ini file as a better solution than my original quick hack, but I've maintained those details for anyone curious. The patch should apply to current dev version; for the latest release (7x.2.10) you may need to apply manually as line numbers have changed.

Original description:
I've been creating custom markers for a site and had been trying to figure out how to go about setting the scaled size property available for marker icons.

The problem is that on high resolution mobile devices, such as iPhone or other mobile phone with great pixel density, markers appear very blurry/pixelated when they would otherwise look crisp on a desktop or laptop. As in many other situations, the proper course of action is to double the dimensions of the graphic to account for the device's doubled pixel count—no problem. And Google Maps code has a property for icons to scale, providing a fairly simple solution to addressing the resolution issue.

Alas, it would not appear that the Drupal implementation here makes use of the scaling property, and I did not see clear, or easy to find, documentation on how to set the property in conjunction with the module.

For anyone looking for a quick and dirty solution:
In the gmap/js/icon.js file, copy line 64 (second value in the "t" object—this is the icon size property, based on actual image width and height) and paste onto new line 67 (now the fifth value in "t" object—setting the icon scaled size property). The key here, for anyone unfamiliar, is that the properties are expected in a specific order if not set directly (as in t.scaledSize = value), and must be set to null unless left off the end of the object definition. On new line 67/scaled size property, divide both the width and height by 2 (should now read "new google.maps.Size(q.sequence[i].w/2, q.sequence[i].h/2)"). Anchor values should be set according to new scaled dimensions.

I'm not rolling a patch for this limited fix, as it seems like a poor overall solution. What would be nice to see is maybe a setting somewhere in the configuration pages, or at least (and even maybe easiest/best) as a value that can be set in marker .ini files. (Set scaling property as a divisor; if it exists, add the property to the end of the object; else leave it null/unset). Maybe I'll work on this better implementation and submit a patch in the next few days, as it seems like a fairly quick and easy one that I just don't have time for immediately.

Or maybe there is another way to do this that I completely overlooked. At any rate, I couldn't find any other issues specifically about this, and figured some documentation of a workaround might benefit someone else.

And just for fun, here is a 2011(!) piece on dealing with markers on retina displays generally in Google maps—some extra information, but perhaps somewhat outdated. The really important piece was exactly what I did (set the scaled size property by adding it to the end of the object), but I did not set the original size or anchor values to null as it suggests, to no apparent problem.
http://samcroft.co.uk/2011/google-maps-marker-icons-for-iphone-retina-di...

Comments

rvallejo created an issue. See original summary.

rvallejo’s picture

Version: 7.x-2.10 » 7.x-2.x-dev
Component: Documentation » Code
StatusFileSize
new2.04 KB

First go at a patch against the default 7.x-2.x.

With this patch, adding a "scale" property in a markers.ini file will be recognized, and will be used to divide the original image width and height. So, for example, a scale value of 2 means that the width and height will both be divided by 2; a 42px x 70px image will scale down to 21px x 35px, and work nicely on high-res mobile screens.

I realize there is a code freeze, but in case anyone else would find it helpful, or if it might by chance apply to an 8.x version as well.

rvallejo’s picture

Issue summary: View changes
rvallejo’s picture

Status: Needs work » Needs review
rvallejo’s picture

Issue summary: View changes
podarok’s picture

Status: Needs review » Fixed

Thanks, merged

  • podarok committed 304bb99 on 7.x-2.x authored by rvallejo
    Issue #2575705 by rvallejo: Scaling GMap Marker Icons for High Res...

Status: Fixed » Closed (fixed)

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