|
|
@ -46,7 +46,7 @@ export class MarkerWithLabel extends MarkerSafe { |
|
|
|
private isMouseDownOnLabel = false; |
|
|
|
private isMouseDownOnLabel = false; |
|
|
|
private shouldIgnoreClick = false; |
|
|
|
private shouldIgnoreClick = false; |
|
|
|
private eventOffset: google.maps.Point | null; |
|
|
|
private eventOffset: google.maps.Point | null; |
|
|
|
private mouseOutTimeout: number; |
|
|
|
private mouseOutTimeout: ReturnType<typeof setTimeout>; |
|
|
|
|
|
|
|
|
|
|
|
constructor(options: MarkerWithLabelOptions) { |
|
|
|
constructor(options: MarkerWithLabelOptions) { |
|
|
|
super({ ...options }); |
|
|
|
super({ ...options }); |
|
|
@ -212,40 +212,48 @@ export class MarkerWithLabel extends MarkerSafe { |
|
|
|
}); |
|
|
|
}); |
|
|
|
abortEvent(e); |
|
|
|
abortEvent(e); |
|
|
|
}), |
|
|
|
}), |
|
|
|
google.maps.event.addListener(this.getMap(), MOUSEMOVE, (e) => { |
|
|
|
google.maps.event.addListener( |
|
|
|
if (this.isMouseDownOnLabel && this.getDraggable()) { |
|
|
|
this.getMap(), |
|
|
|
if (this.isDraggingLabel) { |
|
|
|
MOUSEMOVE, |
|
|
|
// Adjust for offset
|
|
|
|
(e: google.maps.MapMouseEvent) => { |
|
|
|
const position = new google.maps.LatLng( |
|
|
|
if (this.isMouseDownOnLabel && this.getDraggable()) { |
|
|
|
e.latLng.lat() - this.eventOffset.y, |
|
|
|
if (this.isDraggingLabel) { |
|
|
|
e.latLng.lng() - this.eventOffset.x |
|
|
|
// Adjust for offset
|
|
|
|
); |
|
|
|
const position = new google.maps.LatLng( |
|
|
|
// this.setPosition(position);
|
|
|
|
e.latLng.lat() - this.eventOffset.y, |
|
|
|
google.maps.event.trigger(this, DRAG, { |
|
|
|
e.latLng.lng() - this.eventOffset.x |
|
|
|
...e, |
|
|
|
); |
|
|
|
latLng: position, |
|
|
|
// this.setPosition(position);
|
|
|
|
}); |
|
|
|
google.maps.event.trigger(this, DRAG, { |
|
|
|
} else { |
|
|
|
...e, |
|
|
|
this.isDraggingLabel = true; |
|
|
|
latLng: position, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.isDraggingLabel = true; |
|
|
|
|
|
|
|
|
|
|
|
// Calculate and store event offset from marker position
|
|
|
|
// Calculate and store event offset from marker position
|
|
|
|
this.eventOffset = new google.maps.Point( |
|
|
|
this.eventOffset = new google.maps.Point( |
|
|
|
e.latLng.lng() - this.getPosition().lng(), |
|
|
|
e.latLng.lng() - this.getPosition().lng(), |
|
|
|
e.latLng.lat() - this.getPosition().lat() |
|
|
|
e.latLng.lat() - this.getPosition().lat() |
|
|
|
); |
|
|
|
); |
|
|
|
google.maps.event.trigger(this, DRAGSTART, { |
|
|
|
google.maps.event.trigger(this, DRAGSTART, { |
|
|
|
...e, |
|
|
|
...e, |
|
|
|
latLng: this.getPosition(), |
|
|
|
latLng: this.getPosition(), |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}), |
|
|
|
), |
|
|
|
google.maps.event.addListener(this, DRAGSTART, () => { |
|
|
|
google.maps.event.addListener(this, DRAGSTART, () => { |
|
|
|
this.label.zIndex = 1000000; |
|
|
|
this.label.zIndex = 1000000; |
|
|
|
}), |
|
|
|
}), |
|
|
|
google.maps.event.addListener(this, DRAG, ({ latLng }) => { |
|
|
|
google.maps.event.addListener( |
|
|
|
this.setPosition(latLng); |
|
|
|
this, |
|
|
|
}), |
|
|
|
DRAG, |
|
|
|
|
|
|
|
({ latLng }: google.maps.MapMouseEvent) => { |
|
|
|
|
|
|
|
this.setPosition(latLng); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
), |
|
|
|
google.maps.event.addListener(this, DRAGEND, () => { |
|
|
|
google.maps.event.addListener(this, DRAGEND, () => { |
|
|
|
this.label.zIndex = this.getZIndex(); |
|
|
|
this.label.zIndex = this.getZIndex(); |
|
|
|
this.label.draw(); |
|
|
|
this.label.draw(); |
|
|
|