tijmenssmit80/Nomad-World-Map

mapId deducts to non-existent mapId + no default map dimensions

Opened this issue · 0 comments

Hey there,

I discovered a few bugs with this plugin using WP 4.0 on a fresh install. Not very familiar with the project and all the options yet, so no pull request, but here's what I found.

https://github.com/Tijmen/Nomad-World-Map/blob/master/js/nwm-gmap3.js#L156

if ( $( "#nwm-map-1" ).length ) {
  mapId = mapId-1;
} else {
  mapId = 0;
}

This section of the code was preventing my map from rendering entirely. I had one map on a page with an ID of 1 which I was trying to render. So the first condition was satisfied, and the mapId was reduced to 0. But there's no map that existed with an ID of 0, so the rest of the initialization tried to use ID 0 and failed. Once I commented out that mapId-1 line, everything worked fine. Not sure what error this is trying to catch.

Also, the documentation states you can specify a width and a height with the tag like so: [nwm_map height="500" width="500"]. This is, in fact, required for the map to render at all. There are no default height or width styles on the map div, so without explicitly setting the dimensions, they are 0, and the map isn't visible at all.
EDIT: This seems to relate to my other issue #4. Once nwm-outer exists as a wrapper, the map is visible without dimensions specified.

Thanks for your work on this, its exactly the kind of map plugin I was looking for!