ankane / mapkick.js

Create beautiful, interactive maps with one line of JavaScript
https://chartkick.com/mapkick-js
MIT License
399 stars 12 forks source link

Width won't adjust in bootstrap modal #3

Closed pasl closed 1 year ago

pasl commented 1 year ago

Hi

There is a know issue with mapboxgl and when we create a map inside a bootstrap modal the width of the map is not set correctly.

A fix to this is to call map.resize() when the dom is fully loaded.

Would be nice to have a way to access map (mapboxgl) object through Mapkick class.

For example:

var my_map = new Mapkick.Map( "map" ...) my_map.map.resize()

ankane commented 1 year ago

Hey @pasl, thanks for the suggestion! Added a getMapObject() function.

pasl commented 1 year ago

Thanks !

I am using the library with importmap with this link

pin "mapkick", to: "https://ga.jspm.io/npm:mapkick@0.1.1/dist/mapkick.js"

Are you going to make a new release ?

ankane commented 1 year ago

Not right now (planning to make 0.2.0 a bigger release), but you can build dist/mapkick.js with the instructions here.

ankane commented 1 year ago

Just fyi, 0.2.0 is out.

pasl commented 1 year ago

Cool I did a manual import in my projet and I seems to run fine.

Do you know by any chance how to enable the new 0.2.0 version for importmap with JSPM CDN ?

https://generator.jspm.io https://generator.jspm.io/

The new URL should be :

@.***/dist/mapkick.js

I keep getting this error with the generator :

Error: No '.' exports subpath defined in ***@***.***/ resolving mapkick imported from https://generator.jspm.io/.

Le 17 janv. 2023 à 20:28, Andrew Kane @.***> a écrit :

Just fyi, 0.2.0 is out.

— Reply to this email directly, view it on GitHub https://github.com/ankane/mapkick.js/issues/3#issuecomment-1386333571, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHPUN4RDABVP5BDW2BGUJ3WS5BMBANCNFSM6AAAAAAT2ZKPWI. You are receiving this because you were mentioned.

ankane commented 1 year ago

Hey @pasl, this should be fixed in 0.2.1 (just released).

pasl commented 1 year ago

It seems to import fine in the JSPM generator now. At least the error don’t show anymore. I’ll give it a try tomorrow and let you know. Thanks for your work Andrew!Le 19 janv. 2023 à 21:16, Andrew Kane @.***> a écrit : Hey @pasl, this should be fixed in 0.2.1 (just released).

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

pasl commented 1 year ago

For some reasons the JSPM (CDN) importmap link is not the same for version 0.2.1 than for 0.1.1.

0.1.1 = ***@***.***/dist/mapkick.js
0.2.1 = ***@***.***/dist/mapkick.esm.js

Nb: without the .esm v0.2.1 give error:  Importing binding name 'default' cannot be resolved by star export entries.

I was able to make it work in my Rails 7 and impormap with the following configuration:

config / importmap

pin "mapkick",   to: ***@***.***/dist/mapkick.esm.js
pin "mapbox-gl", to: ***@***.***/dist/mapbox-gl.js"

javascript / application.js

import mapboxgl from "mapbox-gl"
window.mapboxgl = mapboxgl
mapboxgl.accessToken = my_token

import Mapkick from "mapkick"
window.Mapkick = Mapkick

I tested it with Safari and Chrome on Macintosh without any issue so far.

Le 19 janv. 2023 à 21:23, Pascal Laplante @.***> a écrit :

It seems to import fine in the JSPM generator now. At least the error don’t show anymore.

I’ll give it a try tomorrow and let you know.

Thanks for your work Andrew!

Le 19 janv. 2023 à 21:16, Andrew Kane @.***> a écrit :



Hey @pasl https://github.com/pasl, this should be fixed in 0.2.1 (just released).

— Reply to this email directly, view it on GitHub https://github.com/ankane/mapkick.js/issues/3#issuecomment-1397844293, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHPUN675HOY3F6DUCWCPYTWTHYPBANCNFSM6AAAAAAT2ZKPWI. You are receiving this because you were mentioned.