-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vue-marker not displaying on map and map not fully rendering #96
Comments
I've had some similar issues. The marker image issue I solved using info from these threads: Basically, sounds like webpack is jacking up the embedded image URLs in the CSS. Throwing this at the top of your
I've gotten to the point that everything renders after the user resizes but I can't figure out why I'm getting grey space before that... |
I ended up with a hack that helped get everything to render correctly as far as the resize issue goes.
This works down to 200 ms. After that the hack fails. Seems to be some sort of race condition. I tested slower bandwidths and they work fine. |
Both those suggestions worked, thanks for the help. |
Hi @qualisign, The icon issue is well known. Leaflet and Webpack don't play well together. You can see the issue #28 and the pull request in Leaflet to fix this. The other issue is the map tiles not loading properly. Mickaël |
The problem for me is that I'm using it along with Vuetity, which includes flexbox-based grid components. I have some tricks to size it as a square, but even before I added that on top I was having issues. I wish I had a simple example to illustrate. |
Never experienced any issue like this on my tests. What do you think? Micka |
Can't hurt to suggest it. Like I said though, I'm using it inside of flexbox. On top of that, I'm binding the height of the map or its container to another property that's computed from the width of a column and stuff. Can't say that everything I'm doing is a good idea, but the whole site is pretty responsive. That's the difficulty with Leaflet to begin with though, it seems. |
Same problem here. Vuetify / Flexbox + gray area showing up. |
I gave a try to Vuetify / Flexbox. I started a Vue project added Vuetify and used this layout. The issue is that if the map container size change Leaflet doesn't know about it and doesn't load tiles to cover the new size of the container. I'm not sure what your issue is as I can't really reproduce it but I think your map container is initialized with a small size(0px ?). The size is increased later but the map doesn't adapt like in my issue so you end up having a mostly grey area. How to fix it :
The second seems to be the only viable choice. What do you guys think? |
In the console if you type:
you might get something like this :
you will notice that the extra double quotes are screwing up the get request.
leave the last double quote |
As for the issue with sizing issue in Vuetify:
then go into the vuetify.css and rip out all of the media queries for the .container class. I think its on lines 9301 to 9313. |
It should be added in your ~/projectName/src/main.js file when you instantiate your Vue object.
|
Many thanks, so simple ... |
Hi, I'm having similar issues as @azurelogic (Vuetify and flexbox rendering here, map is not rendered completely until a resize event). I tried the #96 (comment) solution, but it does not work in my case as my component is mounted when the map object is created (but not necessarily rendered yet). Then, the timeout is not working and it seems super hacky to make it work. I tried with the Did anyone manage to find a working solution for this issue? Thanks! |
@BrandonDevaleriola I'm having this double quote problem, which is causing the GET request to fail. Is there a workaround or did I somehow miss it in your response? |
I've had an issue with the grey area too (also using Vuetify). But I noticed that the issue went away if I change the zoom. So, a very dirty trick that I'm doing is that I programmatically zoom in and out again when the map loads. Then all seems to be fine and it's so fast that it's barely noticeable... not a nice workaround though I admit but none of the other suggestions here helped. |
For anyone having problems with vuetify this is the layout which is working for me:
And on resize I do:
|
Hello guys, If you are facing such problem with vuetifyjs it's most probably that the map container is initialized with a small size. To solve this problem you need to insure that you are loading the map whenever the container is taking the actual size. For example, if you are using dialog as a container for the map, all what you have to do is using 'lazy' prop to insure that the content is rendered on mounted; in other words, the map must be rendered only if the dialog is activated 🎉
I hope this will help some one 😄 |
Building for production, what worked for me was: import 'leaflet/dist/leaflet.css';
import * as L from 'leaflet';
import * as vl from 'vue2-leaflet';
delete (vl as any).L.Icon.Default.prototype._getIconUrl;
(vl as any).L.Icon.Default.mergeOptions({
iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png'),
iconUrl: require('leaflet/dist/images/marker-icon.png'),
shadowUrl: require('leaflet/dist/images/marker-shadow.png'),
}); I'm using TypeScript. And strangely enough, my editor complains that " It's also necessary to have Edit: The workaround I was using was working only for local development with Vue CLI. But didn't work while building for prod. It's working properly for me, after a couple configurations: |
Hi, I was done all stuff that guys said on top, but when I want to use lmap component in v-card of vuetify it disappears. What should i do to fix this? any suggestion? ###Sulotion |
I was experiencing the same issue of leaflet tile not fully loading on the map.
|
I have the same problem (Nuxt + Vuetify).
This works at the first display of the v-bottom-sheet. But, after resizing the browser window and clicking on the button to show the v-bottom-sheet : only a part of the map is displayed.. In another page of the web site, I have a map in a tab panel (https://vuetifyjs.com/en/components/tabs) and I have the same issue : only a part ok the map is displayed. IF you have an universal solution... |
Hi @kaboume ,
As I mentioned above this issue happens because the changes in the container dimensions. However, I recommend you to overcome this issue by force Vue to re-render JUST the map component whenever the button is clicked to show the Keep in mind that if you find yourself needing to force re-rendering any component, maybe you aren't doing something the right way.
You can solve this the same way by using 'lazy' prop in |
Hi @Alhakem , Fot the sheet, the solution to rerender the Map works great!!! (I used the solution described at the bottom of this page : http://michaelnthiessen.com/force-re-render/). I setted a key parameter on the map
and change the value of the componentKey after cliquing on the button to display the sheet
Big thanks to all! |
@kaboume well done 😊👍 |
Is anyone in this thread up to write down in the docs some guidelines that are scattered here? It would be helpful for the next people with the same problems |
I can help with that |
@Alhakem Thanks! Waiting for a docs PR so :) |
When I resize it restores, can someone help me? |
@GopherJ are you using vuetify ? have you read and tried the solution posted in this issue ? |
@DonNicoJs No, I'm not using vuetify. Why when I change tab it influences the map? By the way I'm using keep-alive for router |
Hi, |
Hi,
And I my CarteEtablissement component
And now the map displays correctly and when I show the source of the page, I see the text for the SEO. |
I am so sorry, is there any way to use local set of tiles? from assets folder for example. I can't figure out how to define {z}/{x}/{y} path to local tile set folder. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Posting this here since it seems related. When viewing the examples for custom icons one vue2-leaflet's docs the re-sizable baseball icon that uses an l-icon tag strangley does not work in the provided code on the docs and jsfiddle (https://codesandbox.io/s/51sx6) although it does on the example in the docs itself (https://vue2-leaflet.netlify.com/examples/custom-icons.html). I found a fix for this by simply binding icon-url to a data property that uses require("yourImageDirectoryGoesHere"). Another thing to note is that I am also using the solution posted by @azurelogic in the main.js. |
@dstearle Could you open a new issue to fix the docs? It would be greatly appreciated |
Quick update for those using vuetify 2.0. The lazy prop does not longer work, but v-lazy works:
That will do the trick! |
I have a situation where my I tried many solutions here but the only one I could get to work was to set a watcher on the variable controlling the stepper and use @azurelogic's Template
Script
|
Marker fix for Leaflet in Vue.js, code by azurelogic (2017) vue-leaflet/Vue2Leaflet#96 [Accessed 2021-04-25] This code is needed so the URL for the markers are retrieved from the right location.
This guy right here! pin this somewhere! |
Efectivamente this.$refs.map.mapObject.invalidateSize() no funciona y eso que los tengo en shadodom pero el setTimeOutSiFunciono |
This work for me!! thanks!! |
thanks, it works, but I don't know if it's the cleanest solution :/ |
Description
Steps to Reproduce
Simple
with the following contents (just copied the Simple.vue example and added the style import)Expected Results
I expect to see the basic map with marker from the example jsfiddle.
Actual Results
The map appears as a large gray box with a small section with rendered map tiles. My problem looks identical to the one described in #81 , but I do include the leaflet css import.
What is strange is that when I resize the window, the map loads as it should, but the marker does not show up. I see in the html that the marker is loaded, however:
![leaflet2](https://user-images.githubusercontent.com/13368763/32297265-f04cbf98-bf4e-11e7-8f48-ab31a3abdcc4.png)
Browsers Affected
Versions
The text was updated successfully, but these errors were encountered: