Search code examples
leafletmapquest

Mysterious "markers" using Leaflet (with Omnivore and the MapQuest plugins)


I'm using Leaflet (with omnivore and the MapQuest tile plugins) to display a map with colored polygons. The map and polygons look/work fine, but there are these mysterious blue markers everywhere.

Map with stray markers

There's nothing in the JS about markers at all, and if I comment out the polygon.addTo(map); line, the markers disappear. So they're definitely related to the polygons, even though they're not directly positioned on the polygons.

Any idea why the markers are appearing, or how I can make them disappear?

SOLVED: It turns out that the problem was that I'm using MSSQL's ".Reduce(n)" function to simplify the polygons (for performance), and if you simplify the polygons too far, the results have "Point(...)" items in them - which leaflet renders as markers!

Now, off to figure out why MSSQL is turning things into points...


Solution

  • Welcome to SO!

    Most probably your polygon variable is a Leaflet GeoJSON Layer Group built by the omnivore plugin, and the data you feed it with contains "Point" type geometries.

    If you do not specify anything special to handle these points, Leaflet will render them with this default blue marker icon.

    In that case, you could simply filter out those point features, whether after omnivore processing (use the ready event) or using a custom GeoJSON Layer Group with its filter option. There should be other posts describing such solutions.

    See e.g. Mapbox: Filtering out markers in a Leaflet Omnivore KML layer

    If you are not in this case, you would have to provide more information for people to be able to help you. Typically code that you use to build your polygon layer and sample data.