开发者

GoogleMaps: no custom Icon in IE7

开发者 https://www.devze.com 2023-03-04 16:10 出处:网络
I try to use custom icons for the markers on my map. It works great on FF and IE8, but IE7 only shows the default google markers.

I try to use custom icons for the markers on my map.

It works great on FF and IE8, but IE7 only shows the default google markers.

For creation of the Markers I use the Class LabeledMarker,

the Image is file type image/PNG.

This code is used to create the m开发者_JAVA技巧arker:

var icon = new GIcon();
icon.image = this.options.icon;
icon.iconSize = new GSize(24, 24);
icon.iconAnchor = new GPoint(12, 12);
icon.infoWindowAnchor = new GPoint(12, 0);

point = new GLatLng(this.data['geo_n'], this.data['geo_o']);

var opts = {
    icon: icon,
    clickable: false,
    labelText: 'test'
};

marker = new LabeledMarker(point, opts);
map.addOverlay(marker)


OK, the problem was something else. I know that I hate for-loops in IE.

There is a for-loop that iterates over a config-array to find the right icon to display.
for(i in cfg.icons[key]){
Like this in the first iteration i had the value 'rgbToHex' and caused my script to abort

Replaced with this all my scripts work great now:
for(var i = 0; i < cfg.icons[key].length; i++){

0

精彩评论

暂无评论...
验证码 换一张
取 消