0

我在 api 1.0 中有这种样式

var s = new YMaps.Style();
s.iconStyle = new YMaps.IconStyle();
s.iconStyle.offset = new YMaps.Point(-1, -30);
s.iconStyle.href = "http:www.example.com/images/1.png";
s.iconStyle.size = new YMaps.Point(29, 28);
s.iconStyle.shadow = new YMaps.IconShadowStyle();
s.iconStyle.shadow.offset = new YMaps.Point(2, -12);
s.iconStyle.shadow.href = "http:www.example.com/images/2.png";
s.iconStyle.shadow.size = new YMaps.Point(29, 7);

在这里,我将此样式添加到地标

var placemark = new YMaps.Placemark(new YMaps.GeoPoint(lat, long),
                            {hasBalloon: false,
                              style: s
                            });
                          placemark.setHintContent(mystring);
                          placemark.enableHint();
                          map.addOverlay(placemark);

如何在 api 2.0 中创建这种样式?

4

1 回答 1

1

我这样解决:

placemark.options.set('iconImageHref', 'http:www.example.com/images/1.png');
                placemark.options.set('iconImageOffset', [-1, -30]);
                placemark.options.set('iconImageSize', [28,29]);
placemark.options.set('iconShadowImageHref', 'http:www.example.com/images/2.png');
                placemark.options.set('iconShadowImageOffset', [2, -12]);
                placemark.options.set('iconShadowImageSize', [29, 7]);
于 2014-03-19T12:49:17.403 回答