Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adjusting featureanimation example #86

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions examples/animation/map.featureanimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ import { Coordinate } from 'ol/coordinate';
import 'ol-ext/render/AnimExtent';
import featureAnimation from 'ol-ext/featureanimation/FeatureAnimation';
import { getKey } from 'ol/tilecoord';

declare global {
interface Window {
$(selector: any, context?: any): any,
add10(): void
}
}
const $ = window.$;

// Layers
let layer = new TileLayer({
source: new Stamen({ layer: 'terrain' }),
Expand Down Expand Up @@ -113,12 +122,12 @@ function addFeatureAt(p: Coordinate) {

vector.getSource()?.addFeature(f);
vector.animateFeature(f, [
new featureAnimation[$('#anim').text()] ({
new featureAnimation[$('#anim').val()] ({
speed: Number($('#speed').val()),
duration: Number(1000 -Number($('#speed').val()) * 300),
side: $('#side').prop('checked'),
}),
new featureAnimation[$('#anim2').text()]({
new featureAnimation[$('#anim2').val()]({
speed: Number($('#speed').val()),
duration: Number(1000 - Number($('#speed').val()) * 300),
horizontal: /Slide/.test($('#anim').text()),
Expand All @@ -139,6 +148,9 @@ function add10() {
}, 100 * i);
}
}
window.add10 = (): void => {
add10();
}
add10();

// Drop a feature on click
Expand All @@ -154,7 +166,7 @@ map.on('singleclick', function (evt) {
vector.getSource()?.removeFeature(f);
// Show animation
vector.animateFeature(f, [
new featureAnimation[$('#anim').text()]({
new featureAnimation[$('#anim').val()]({
speed: Number($('#speed').val()),
duration: Number(1000 - Number($('#speed').val()) * 300),
side: $('#side').prop('checked'),
Expand Down