0

I'm working on a tool that allows users to draw geometries on a Leaflet map, which are then sent to CartoDB. However, I've noticed an odd behavior... after a polygon has been added, a varying number of seemingly random points get added to the map as well.

For example, I drew a rough polygon of Manhattan, but here's what the map displays...

enter image description here

What strikes me as particularly odd is that, if I remove the polygon CartoCSS, the points remain... some of them can be clicked on and the little info window that pops up correspond to the ID of the polygon, but others are unclickable.

For reference, here is the data from the_geom column for the Manhattan polygon...

{"type":"Polygon",
 "coordinates":
               [
                [
                 [-74.00802612,40.75037809]
                 [-74.01626587,40.70250471],
                 [-73.9956665,40.70979201],
                 [-73.9805603,40.71499674],
                 [-73.97232056,40.74517613],
                 [-73.93112183,40.79821703],
                 [-73.9352417,40.8335541],
                 [-73.91052246,40.87302619],
                 [-73.92837524,40.87614141],
                 [-74.00802612,40.75037809]
                ]
               ]
}

And I checked these... not one of them corresponds to these mystery points.

Does anyone know why this is happening and what I can do about it?

  • Can you check, what your leaflet client is actually sending to the server? Try the developer tools (firebug in mozilla) in your browser via pressing F12 and check in the Network tab. Maybe it's sending malformed geometries containing points as well. – ulrich Apr 25 '16 at 22:33
  • As far as I can see, everything looks good - I just did a rough outline of Wyoming and the same problem occurred. The data insert is handled by PHP, and the network tab on that page showed the following: {"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-111.09374999999999,45.02695045318546],[-111.07177734375,40.979898069620155],[-104.0625,41.0130657870063],[-104.0625,45.02695045318546],[-111.09374999999999,45.02695045318546]]]}} which is correct (I clean up the GeoJSON in the PHP before passing into CartoDB) – skwidbreth Apr 25 '16 at 22:49
  • It does appear to me that at least one of the phantom points is the polygon centroid, but the others have no discernible relation to the polygon... – skwidbreth Apr 25 '16 at 22:50
1

Well, I'm not sure of the source of these mystic points, but I can at least hide them by removing marker styles from the CartoCSS. I was reluctant to do that at first, because I wanted my map to display point, line, and polygon types, and I was concerned that I wouldn't be able to display legit points without getting these suckers in the way. However, I consulted with someone who's been close with the CartoDB folks for a long time, and he advised that I simply store different geometry types in different layers and style accordingly.

  • Other things, that come to my mind would be to remove the points via API. Also, do you have the points on a different layer, so you might be able to hide the points layer? – ulrich Apr 26 '16 at 8:44
  • 1
    Exactly. CartoDB doesn't support multiple geometry types in a single layer. Points CartoCSS applied to polygons will cause those points you're seeing there. – iriberri Apr 26 '16 at 9:19
  • @tareq - to clarify, this was only one layer, and it was only storing polygons - these points were not stored in another layer, they were appearing on their own... however, I planned to add different geometry types as well, which was why I was initially concerned. – skwidbreth Apr 26 '16 at 17:02

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.