remove shadowOffset, add shadowAnchor
This commit is contained in:
parent
b30df4a0fd
commit
0cadad7a1d
@ -52,7 +52,7 @@ Icon API was improved to be more flexible, but one of the changes is backwards-i
|
||||
* Converted `Icon` properties to options, changed constructor signature to `Icon(options)`.
|
||||
* Moved default marker icon options to `L.Icon.Default` class (which extends from `L.Icon`).
|
||||
* Added `Icon` `className` option to assign a custom class to an icon.
|
||||
* Added `Icon` `shadowOffset` option to set the position of shadow relative to the icon.
|
||||
* Added `Icon` `shadowAnchor` option to set the anchor of the shadow.
|
||||
* Made all `Icon` options except `iconUrl` optional (if not specified, they'll be chosen automatically or implemented using CSS). Anchor is centered by default (if size is specified), and otherwise can be set through CSS using negative margins.
|
||||
|
||||
#### Other breaking API changes
|
||||
|
@ -7,6 +7,7 @@ L.Icon = L.Class.extend({
|
||||
popupAnchor: (Point) (if not specified, popup opens in the anchor point)
|
||||
shadowUrl: (Point) (no shadow by default)
|
||||
shadowSize: (Point)
|
||||
shadowAnchor: (Point)
|
||||
*/
|
||||
className: ''
|
||||
},
|
||||
@ -42,17 +43,18 @@ L.Icon = L.Class.extend({
|
||||
_setIconStyles: function (img, name) {
|
||||
var options = this.options,
|
||||
size = L.point(options[name + 'Size']),
|
||||
anchor = L.point(options.iconAnchor),
|
||||
offset = L.point(options.shadowOffset);
|
||||
anchor;
|
||||
|
||||
if (name === 'shadow') {
|
||||
anchor = L.point(options.shadowAnchor || options.iconAnchor);
|
||||
} else {
|
||||
anchor = L.point(options.iconAnchor);
|
||||
}
|
||||
|
||||
if (!anchor && size) {
|
||||
anchor = size.divideBy(2, true);
|
||||
}
|
||||
|
||||
if (name === 'shadow' && anchor && offset) {
|
||||
anchor = anchor.add(offset);
|
||||
}
|
||||
|
||||
img.className = 'leaflet-marker-' + name + ' ' + options.className;
|
||||
|
||||
if (anchor) {
|
||||
|
Loading…
Reference in New Issue
Block a user