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];
}
if (L.Browser.retina && name == 'icon') {
name += '@2x';
}
var path = L.Icon.Default.imagePath;
if (!path) {

View File

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