Hi all,
I just tried changing my markers to use a MarkerImage instead of just
an icon, as I wanted to change the anchor point. What I'm seeing is
that the API doesn't seem to realise that it's been given a
MarkerImage object instead of a string to a URL. This is the function
I am using:
function AddVehicleMarkerToMap(vehicleObj) {
var vehLatLng = new google.maps.LatLng(vehicleObj.lat,
vehicleObj.lon);
var vehIcon = VEHICLE_ICONS_BASE_URL + "/vehicles" +
vehicleObj.logo + ".gif";
var anchorPoint = new google.maps.Point({x:12,y:12});
var markerImage = new
google.maps.MarkerImage({url:vehIcon,anchor:anchorPoint});
var vehicleMarker = new google.maps.Marker ({
flat: true,
icon: markerImage,
position: vehLatLng,
visible: true,
zIndex:1000,
map: map
});
vehicleObj.marker = vehicleMarker;
vehicleObj.RemoveFromMap = function()
{vehicleObj.marker.setMap(null);}
vehicleList.push(vehicleObj);
AddListeners(vehicleMarker);
}
vehIcon is holds a correct value (and is a 24x24 gif). If I use the
debugger on IE8 I can see that everything looks to be correct
(although the Point object within markerImage does "look" a bit odd,
as it has x and y properties, with y underfined, but with another x
and y under x, but I'll dismiss that as obfuscation weirdness!).
Fiddler shows me that it is trying to access this to get the icon:
http://dev.fleetstar-online.com/[object%20Object]
In other words, it seems to have not realised it is actually a
MarkerImage object, although the debugger shows me that the icon
property is indeed an object not a string. Have I missed something
crucial or is this a bug? I can't see a way to tell the API I'm using
a MarkerImage object explicitly, the documentation seems to imply that
either can be passed in.
Thanks,
-Neil
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
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.