Skip to content

Commit

Permalink
3.11.1
Browse files Browse the repository at this point in the history
## 3.11.1
- Fixed issue where opening a map with a marker type that no longer exists would fail to render the map
- #38 - Fixed issue where bulk editing markers on maps with command markers was not respecting the Command Marker toggle
- #25 - Removed maxZoom constraint from Show All Markers control button
  • Loading branch information
valentine195 committed May 24, 2021
1 parent 0709bae commit ec29309
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 20 deletions.
16 changes: 11 additions & 5 deletions src/leaflet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,20 @@ class LeafletMap extends Events {
command: boolean = false,
zoom: number = this.zoom.max
): ILeafletMarker {
const mapIcon =
this.markerIcons.find(({ type }) => type == markerIcon?.type || "")
?.icon ??
this.markerIcons.find(({ type }) => type === "default").icon;
let mapIcon = this.markerIcons.find(
({ type }) => type === "default"
).icon,
type = "default";
if (markerIcon && markerIcon.type) {
mapIcon = this.markerIcons.find(
({ type }) => type == markerIcon.type ?? "default"
)?.icon;
type = markerIcon.type;
}

const marker = new Marker({
id: id,
type: markerIcon.type ?? "default",
type: type,
loc: loc,
link: link,
icon: mapIcon,
Expand Down
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ declare module "obsidian" {
commands: {
listCommands(): Command[];
executeCommandById(id: string): void;
findCommand(id: string): Command;
commands: { [id: string]: Command };
};
keymap: {
Expand Down
54 changes: 39 additions & 15 deletions src/map/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { LAT_LONG_DECIMALS } from "../utils/constants";
import { icon } from "../utils/icons";
import { getId, getImageDimensions } from "../utils";

import { PathSuggestionModal } from "../modals";
import { CommandSuggestionModal, PathSuggestionModal } from "../modals";

import { Events, Modal, Notice, Setting, TextComponent } from "obsidian";
import { IconName } from "@fortawesome/free-solid-svg-icons";
Expand Down Expand Up @@ -83,7 +83,7 @@ export class DistanceDisplay extends L.Control {
duration: 0.5,
easeLinearity: 0.1,
animate: true,
padding: [3, 3]
padding: [5, 5]
}
);
}
Expand Down Expand Up @@ -269,7 +269,8 @@ class EditMarkerControl extends FontAwesomeControl {
"",
getId(),
this.map.mapLayers[0].id,
true
true,
false
);
this.display(markersEl);
});
Expand Down Expand Up @@ -330,12 +331,25 @@ class EditMarkerControl extends FontAwesomeControl {
};
})
.addText((t) => {
let files = this.plugin.app.vault.getFiles();

t.setPlaceholder("Path").setValue(marker.link);
const modal = new PathSuggestionModal(this.plugin.app, t, [
...files
]);
t.setPlaceholder("Path");
let modal;
if (marker.command) {
const commands =
this.plugin.app.commands.listCommands();
t.setValue(
this.plugin.app.commands.findCommand(marker.link)
?.name ?? "Command not found!"
);
modal = new CommandSuggestionModal(this.plugin.app, t, [
...commands
]);
} else {
t.setValue(marker.link);
const files = this.plugin.app.vault.getFiles();
modal = new PathSuggestionModal(this.plugin.app, t, [
...files
]);
}
modal.onClose = () => {
marker.link = t.getValue();
};
Expand Down Expand Up @@ -468,7 +482,8 @@ class SimpleLeafletMap extends Events {
oldMarker.link,
oldMarker.id,
oldMarker.layer,
oldMarker.mutable
oldMarker.mutable,
oldMarker.command
);
}
}
Expand All @@ -478,7 +493,8 @@ class SimpleLeafletMap extends Events {
link: string | undefined = undefined,
id: string,
layer: string | undefined = undefined,
mutable: boolean
mutable: boolean,
command: boolean
) {
const mapIcon = this.original.markerIcons.find(
({ type: t }) => t == type
Expand All @@ -492,7 +508,7 @@ class SimpleLeafletMap extends Events {
icon: mapIcon,
layer: layer,
mutable: mutable,
command: false,
command: command,
zoom: this.original.zoom.max
});

Expand Down Expand Up @@ -592,9 +608,17 @@ class ZoomControl extends FontAwesomeControl {
this.leafletInstance.fitWorld();
return;
}
this.leafletInstance.fitBounds(group.getBounds().pad(0.5), {
maxZoom: this.map.zoom.default
});
this.leafletInstance.fitBounds(
group.getBounds(),
{
maxZoom: this.leafletInstance.getBoundsZoom(group.getBounds())
} /* {
duration: 0.5,
easeLinearity: 0.1,
animate: true,
padding: [50, 50]
} */
);
}
}

Expand Down

0 comments on commit ec29309

Please sign in to comment.