Topic: VectorMap is not a constructor

MyHomeTendance priority asked 2 years ago


I'm developping a tool for which I need your VectorMaps. This plugin used to work just fine with my custom SVG map, but lately it stopped working.

Expected Behaviour : VectorMap proper initialization via JS.

Actual Behaviour : Whenever I try to initialize a new VectorMap() via JS I get an error in my console telling me Uncaught TypeError: VectorMap is not a constructor.

First I thought this was a problem with my own code, but then I downloaded again the whole MDB5 library from the Orders list and tried to make a new VectorMap in the index.html provided with it, just to test. Same problem.

<!-- Test div, inside of the container in the index.html file -->    
<div id="vector_map_test"></div>

<!-- JS script, inside the last script element you can find in the index.html file -->
new VectorMap(document.getElementById('vector_map_test'), { readonly: true, stroke: '#fff', colorMap: [{ fill: '#E0E0E0', regions: ['GB', 'PL']}] })

Any ideas ?

EDIT : I'm realizing now that according to the folder's name, my version of MDB5 is 3.6.0, not 3.5.1

I have the MDB5 Standard UI Kit Pro Advanced 3.6.0 (hope this helps)

EDIT 2 : I've been trying to make this work again so I downgraded gradually my MDB version thanks to your pro repo. I figured out it stopped working on version 3.5.0. I downgraded to latest commit on 3.4.0 and VectorMaps work again. Hope this helps debugging things.


Dawid Wajszczuk staff commented 2 years ago

Hi. It is weird, because in our repository everything seems to work fine. Are you sure that there is no extra code added? I will check it again in our repository.


MyHomeTendance priority commented 2 years ago

I'm absolutely certain there's nothing else. As I told you in my original post, to make sure this didn't come from me I downloaded again MDB5 from my orders list and tried to make a new VectorMap directly in the index.html provided with it, so no additional code at all (just one div and the new VectorMap as specified in the post). Got the error. Then I tried the same steps again with the versions available on your repo (3.6.0, 3.5.1, 3.5.0 and latest 3.4.0) and VectorMap only works with the 3.4.0. I wish I could help further. Any other ideas ?


MyHomeTendance priority commented 2 years ago

@AgentSmith thanks for the tip, I don't really want to initialize it this way though so I think I'll just stick with MDB5 3.4.0 until problem's solved. At least I see we're not the only ones to have this problem. I was starting to wonder what I could have done to break it but I can't see any option.


Dawid Wajszczuk staff answered 2 years ago


Hi,

I have checked it again and there is definitely some kind of bug since version 3.5.0. At this moment I wasn't able to locate this bug and come up with solution. Try what @AgentSmith has suggested, initialize via jQuery. We will try to fix this bug as soon as possible. And thanks for all this information.

Keep coding,
Dawid


MyHomeTendance priority commented 2 years ago

@Dawid Wajszczuk Sorry I saw you answer later than the comment above. I'll stick with 3.4.0 for now as we don't want to use JQuery if we only need it for one VectorMap initialization. I'm happy to see that you know there's a problem in the code though. Means that you'll eventually fix it and we'll be able to update again at some point. Thanks !



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.5.1
  • Device: Computer
  • Browser: Chromium
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No