I'm working on switching from OpenLayers 2 to OpenLayers 3 and supplementing my reading of The Book of OpenLayers 3 by trying some things out on my own. There's a project that I'm building here that should be fairly simple: take form inputs and use them as parameters for building a vector layer. The interface works as intended, save for one problem.

Whenever I pan the map or zoom it, the vector layer seems to disappear. I can't for the life of me imagine what's going on. Anyone able to help me figure out what I can do to keep the layer in place?

To make things easier, I have created a JSFiddle, please feel free to use at will.

  • Welcome to GIS.SE. You might be better off putting the code on jsFiddle or similar and producing a minimal example demonstrating the problem. At the moment that is a lot of code to read through. Feb 25 '16 at 6:36
  • Hi! I linked to the project inline, added the code as a courtesy for those who didn't want to click through. If that is not in accordance with GIS.SE custom, I'll be happy to remove it! Feb 25 '16 at 6:40
  • The reason that jsFiddle and the like is preferable, is because you can see the output and code side by side, and someone can update with a fix and post that. It is now possible to see your issue, but harder to see the code. Feb 25 '16 at 7:31
  • Point taken! Sorry, I am new to SE, generally, still getting my sea legs. I'll edit to include a JSFiddle link. Feb 25 '16 at 7:40
  • Perfect. I wish everyone found their sea legs this quickly :-) Feb 25 '16 at 8:22

The answer was in line 77 here. It turns out that for whatever reason, I misunderstood falsiness in JavaScript and my style-builder function was erring on undefined styles. Who knew? The rest of the code works, though!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.