{Urgent]Marker popup is not working in case of rotation of the map

Topics: SharpMap Project, SharpMap v0.9 / v1.x, SharpMap v2.0, WinForms Controls
Oct 18, 2010 at 7:59 PM

Hi fobermaier,

Now I am able to create pop with  void mapImage_MapQueried(SharpMap.Data.FeatureDataTable data) function.

but only problem I am facing now is if I rotate a map and then try to click on any marker then marker click is not working properly,it means that it's showing worng data in popup.

Please let me know what I have to do for this. so that in case of rotation of the map marker click event will work properly with right information.

If I will resolve this issue then I will share my code so that each user can see, how we can make popup in sharp map.

Thanks,

Vivek Kumar

Coordinator
Oct 19, 2010 at 10:08 AM

hello vivek,

do you get the same data for every marker, is it the last,

you can send your code via email if you want me to look at it prior to offering a patchfile

Hth FObermaier

 

Oct 19, 2010 at 11:33 AM

HI Hth FObermaier,

I sent a email regarding this.

Please check it.

Thanks,

Vivek

Oct 19, 2010 at 12:55 PM

Hi Hth FObermaier,

please let me know if you have any question regarding this.

Thanks,

Vivek Kumar

Coordinator
Oct 20, 2010 at 7:59 AM

Hello Vivek,

assuming you use some modification of MapImage control, you will need to change some code in MapImage_MouseUp event:

 

else if (ActiveTool == Tools.Query)
{
  if (_Map.Layers.Count > _queryLayerIndex && _queryLayerIndex > -1)
  {
    if (_Map.Layers[_queryLayerIndex] is ICanQueryLayer)
    {
        ICanQueryLayer layer = _Map.Layers[_queryLayerIndex] as ICanQueryLayer;
        System.Drawing.Point pt;
        if (!Map.MapTransform.IsIdentity)
        {
            System.Drawing.Drawing2D.Matrix mat = Map.MapTransform;
            mat.Invert();
            System.Drawing.Point[] pts = new System.Drawing.Point[1];
            pts[0] = new System.Drawing.Point(e.X, e.Y);
            mat.TransformPoints(pts);
            pt = pts[0];
        }
        else
        {
            pt = new System.Drawing.Point(e.X, e.Y);
        }
        BoundingBox bbox =
            _Map.ImageToWorld(pt).GetBoundingBox().Grow(_Map.PixelSize * 5);
        FeatureDataSet ds = new FeatureDataSet();
        layer.ExecuteIntersectionQuery(bbox, ds);
        if (MapQueried != null)
        {
            if (ds.Tables.Count > 0)
                MapQueried(ds.Tables[0]);
            else
                MapQueried(new FeatureDataTable());
        }
    }
  }
}

 

The issue is that you need to re-transform the point clicked to the original orientation of the map.

Hth FObermaier

Oct 22, 2010 at 9:14 AM

Hi Felix,

I just sent a Deatiled email to you.

Thanks for your support and time.

Regards,

Vivek Kumar.

Oct 24, 2010 at 5:24 PM

Hi Felix,

Please let me know if you have something.

Thanks,

Vivek

Coordinator
Oct 25, 2010 at 8:14 AM

Hello Vivek,

try latest version from Trunk, MapImage control has PanOrQuery tool.

It behaves as follows:

- Query on click,

- Pan on drag

In addition it extends the Envelope of the map in case of rotation so that all features that should be in viewport are rendered.

Hth FObermaier