Add iconRetinaUrl and shadowRetinaUrl to set urls for retina icons. Add a retina version of the default icon and use it.

This commit is contained in:
danzel 2012-11-26 15:00:54 +13:00
parent 003cf55451
commit 946a9df5f9
3 changed files with 9 additions and 0 deletions

BIN
dist/images/marker-icon@2x.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -16,6 +16,10 @@ L.Icon.Default = L.Icon.extend({
return this.options[key]; return this.options[key];
} }
if (L.Browser.retina && name == 'icon') {
name += '@2x';
}
var path = L.Icon.Default.imagePath; var path = L.Icon.Default.imagePath;
if (!path) { if (!path) {

View File

@ -2,10 +2,12 @@ L.Icon = L.Class.extend({
options: { options: {
/* /*
iconUrl: (String) (required) iconUrl: (String) (required)
iconRetinaUrl: (String) (optional, used for retina devices if detected)
iconSize: (Point) (can be set through CSS) iconSize: (Point) (can be set through CSS)
iconAnchor: (Point) (centered by default, can be set in CSS with negative margins) iconAnchor: (Point) (centered by default, can be set in CSS with negative margins)
popupAnchor: (Point) (if not specified, popup opens in the anchor point) popupAnchor: (Point) (if not specified, popup opens in the anchor point)
shadowUrl: (Point) (no shadow by default) shadowUrl: (Point) (no shadow by default)
shadowRetinaUrl: (String) (optional, used for retina devices if detected)
shadowSize: (Point) shadowSize: (Point)
shadowAnchor: (Point) shadowAnchor: (Point)
*/ */
@ -83,6 +85,9 @@ L.Icon = L.Class.extend({
}, },
_getIconUrl: function (name) { _getIconUrl: function (name) {
if (L.Browser.retina && this.options[name + 'RetinaUrl']) {
return this.options[name + 'RetinaUrl'];
}
return this.options[name + 'Url']; return this.options[name + 'Url'];
} }
}); });