Giter Site home page Giter Site logo

mapbox-gl-animated-popup's Issues

typescript support

Type error: Could not find a declaration file for module 'mapbox-gl-animated-popup'. /node_modules/mapbox-gl-animated-popup/dist/mapbox-gl-animated-popup.js' implicitly has an 'any' type.

With Mapbox-gl.js v2.6.1, popups no longer animate from "bottom-to-top" or "top-to-bottom". They now only animate "from-center-exploding-outward".

Issue
The popup animation loads from the central spot of the popup div, and not from the anchor position (i.e. the triangle along the bottom/top of the popup depending on the marker position on the map when clicked).

Working Example of Issue:
JSFiddle Demo
(If the JSfiddle doesn't load for you, check that a browser extension isn't preventing the canvas from loading)

Once in the Fiddle:

  1. Put your YOUR_MAPBOX_ACCESS_TOKEN into the javascript section of the fiddle
    --- (if you need one, you can get access token by signing up at mapbox.com)
  2. Click Run (top right corner)

To Reproduce Issue:
Click on the Marker, and notice the animation begins from the center of the div regardless.

And now switch:

<script src="https://api.mapbox.com/mapbox-gl-js/v2.6.1/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v2.6.1/mapbox-gl.css" rel="stylesheet" />

to

<script src="https://api.mapbox.com/mapbox-gl-js/v2.4.1/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v2.4.1/mapbox-gl.css" rel="stylesheet" />

Then animation works with its correct expected behavior... The example on the popup animation website uses v2.3.1, and as demoed it also clearly works with v2.4.1. I have not tested other combinations mapbox-gl versions, but the latest of v2.6.1 (as of Dec 2021) clearly causes issue. Is this an issue with mapbox-gl javascript or the animated-popup javascript?

For completeness, I ever remove the JSFiddle the jsfiddle code was as follows:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Attach a popup to a marker instance</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://api.mapbox.com/mapbox-gl-js/v2.6.1/mapbox-gl.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/mapbox-gl-animated-popup.min.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v2.6.1/mapbox-gl.css" rel="stylesheet" />
<style>
  body { margin: 0; padding: 0; }
  #map { position: absolute; top: 0; bottom: 0; width: 100%; }
</style>
</head>
<body>
<style>
    #marker {
        background-image: url('https://docs.mapbox.com/mapbox-gl-js/assets/washington-monument.jpg');
        background-size: cover;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        cursor: pointer;
    }

    .mapboxgl-popup {
        max-width: 200px;
    }
</style>

<div id="map"></div>

<script>
// put your personal mapbox access token here to load the map
    mapboxgl.accessToken = 'YOUR_MAPBOX_ACCESS_TOKEN';
    var monument = [-77.0353, 38.8895];
    var map = new mapboxgl.Map({
        container: 'map',
        style: 'mapbox://styles/mapbox/light-v10',
        center: monument,
        zoom: 15
    });

    // create the popup
    var popup = new AnimatedPopup({
        offset: 25,
        openingAnimation: {
            duration: 1000,
            easing: 'easeOutElastic'
        },
        closingAnimation: {
            duration: 300,
            easing: 'easeInBack'
        }
    }).setText(
        'Construction on the Washington Monument began in 1848.'
    );

    // create DOM element for the marker
    var el = document.createElement('div');
    el.id = 'marker';

    // create the marker
    new mapboxgl.Marker(el)
        .setLngLat(monument)
        .setPopup(popup) // sets a popup on this marker
        .addTo(map);
</script>

</body>
</html>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.