raptorswing / MapGraphics

A tile-based "slippy map" library written in/for C++/Qt. It's meant to enable C++/Qt developers to easily add nice, interactive maps to their applications. Supports zooming, rotating, interactive custom map objects, transparency, etc. It is a Qt map widget that can use tiles from MapQuest, Openstreetmap, or a custom source you define.
Other
163 stars 77 forks source link

PolygonObject painting as if open, Only repainting at certain zoom levels #18

Open mattbbernstein opened 9 years ago

mattbbernstein commented 9 years ago

First off, this library is excellent. It's exactly what I've been looking for for my application. However I'm experiencing some unexpected behavior and I'm not sure if it's working as intended or it's a bug.

  1. I create a PolygonObject by clicking a few places on the map and saving the longitude/latitude as points in a QVector then creating a QPolygonF from that vector and finally building a PolygonObject from that polygon. I know the points are being saved correctly since once it paints it's painting the vertices in the correct places, my issue is that it's not just filling the polygon, it's filling the entire map. And on top of this, the fill behavior gets really wonky if the angles become too acute or if I try to draw something like a chevron.
  2. Is there anyway to force it to repaint immediately? If I'm zoomed in at like level 10, once I draw an object, I have to zoom out for it to draw, otherwise it doesn't display. Once it's drawn I have no trouble and it scales correctly, but in order to get it to populate I need to zoom out

Thanks again!

raptorswing commented 8 years ago

Hi -

I'm glad that you've found the library useful so far.

  1. It doesn't sound like you're doing anything unreasonable here... I haven't seen this behavior before. Could you post a screenshot? Also if possible a minimal code sample to reproduce the issue would be helpful.
  2. I think that if you call .update() on the map view it should schedule a repaint. Or if you really want to force it you could call .repaint()... but this should not be necessary. I haven't seen this issue before. Can you post a screenshot? What platform and version of Qt are you using ?

Thanks.

On Wed, Jul 8, 2015 at 12:29 PM, mattbbernstein notifications@github.com wrote:

First off, this library is excellent. It's exactly what I've been looking for for my application. However I'm experiencing some unexpected behavior and I'm not sure if it's working as intended or it's a bug.

1.

I create a PolygonObject by clicking a few places on the map and saving the longitude/latitude as points in a QVector then creating a QPolygonF from that vector and finally building a PolygonObject from that polygon. I know the points are being saved correctly since once it paints it's painting the vertices in the correct places, my issue is that it's not just filling the polygon, it's filling the entire map. And on top of this, the fill behavior gets really wonky if the angles become too acute or if I try to draw something like a chevron. 2.

Is there anyway to force it to repaint immediately? If I'm zoomed in at like level 10, once I draw an object, I have to zoom out for it to draw, otherwise it doesn't display. Once it's drawn I have no trouble and it scales correctly, but in order to get it to populate I need to zoom out

Thanks again!

— Reply to this email directly or view it on GitHub https://github.com/raptorswing/MapGraphics/issues/18.

mattbbernstein commented 8 years ago

So I'm using QT 5.5 on Windows 7.

So I edited my code so that when I click on the map I store a point and display a circle. Once I double click, It draws lines and then creates a PolygonObject. The new issue is that 1. it only draws the polygon once I've zoomed out to about level 2 or 3 and 2. the fill is bounded and the right shape but only fits at zoom level 17 (2nd to last) even if I draw in a different level.

Picture 1: 4 Points have chosen and a PolygonObject has been created but isnt filled in 2points

Picture 2: I've zoomed out to about level 4 or 5 and the fill first appears fill-first

Picture 3: Zoomed back into my original view. The fill size stays the same so I think there is an issue with the coordinates or zoom invariance origwithfill

Picture 4: Zoom level 17, the only time the fill fits the polygon lv17withfill

Code section called everytime a point is clicked on the map (when drawing is enabled): new_point_code

"window" inherits MapGraphicsView so I could use the mouse handlers getCurrentPoint() retrieves the most recent click (stored on click in the handler). The mouse location ( event->locPos() ) is parsed through mapToScene() to translate the local mouse position to (longitude, latitude)

Code section called upon double click and finishing the shape end_shape_code

Draws the connecting edge, creates a PolygonObject and then adds both to the scene.

Thanks for the help!