Here is what is causing it, but don“t know why this happens only when
loading from scratch.
Each marker gets an custum photo-icon. For that I have to create
a google.maps.MarkerImage. To maintain the photo side-ratio, I have to give
the MarkerImage the correct width and height. To get them, I create an
Javascript Image object, which I load with the url of the icon, then
retrieve the width and height property and divide both to get the variable
img_ratio.
For some reason, when loading the page from scratch, the width and height
of the Javascript Image object are Null, after setting the correct
src-attribute, causing the variable img_ratio to be NaN. Now that I know
that, I can set img_ratio arbitrarily to 1, which causes the icons to be
quadratic, but at least they appear.
Somebody have an idea, why this is happening?
$.each(res.users, function(index, value)
{
var spotid = unescape(value.Name);
var point = new google.maps.LatLng(value.Lat, value.Lng);
var title = unescape(value.Name);
var folder = unescape(value.Folder);
var icon = unescape(value.Photo);
var description = unescape(value.Description);
var img = new Image();
img.src = icon;
alert(icon + ": " + img.width + " x " + img.height);
var img_ratio = parseFloat(img.height) / parseFloat(img.width);
if(isNaN(img_ratio))
img_ratio = 1;
var icon_size = new google.maps.Size(m_NormalImageSize, m_NormalImageSize *
img_ratio);
var shadow_size = new google.maps.Size(m_NormalShadowSize,
m_NormalShadowSize * img_ratio);
var image = new google.maps.MarkerImage(
icon,
icon_size,
new google.maps.Point(0,0),
new google.maps.Point(-3, m_NormalImageSize * img_ratio + 3 * img_ratio),
icon_size
);
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-maps-js-api-v3/-/yriSh1S-ezQJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.