This is a migrated thread and some comments may be shown as answers.

Drag and Drop on the map

7 Answers 158 Views
Map
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Simon Störmer
Top achievements
Rank 1
Simon Störmer asked on 23 Mar 2011, 10:45 AM
Hi,

I try to do a drag and drop operation on the map. I have a MapPolyline and a MapRectangle. I want to drop the rectangle onto the MapPolyline to add the coordinate of the dragged MapRectangle to the polyline.

I use the following markup:

<telerik:RadMap x:Name="radMap"
                        Center="40, -100"
                        ZoomLevel="7"
                        MouseClickMode="None"
                       
                    >
       
      <telerik:RadMap.Provider>
        <telerik:OpenStreetMapProvider />
      </telerik:RadMap.Provider>
 
      <telerik:InformationLayer Name="LineLayer"  >
        <telerik:MapPolyline Stroke="Red" StrokeThickness="15" telerik:RadDragAndDropManager.AllowDrop="True" >
          <telerik:MapPolyline.Points>
            <telerik:LocationCollection>
              <telerik:Location Latitude="40" Longitude="-100" />
              <telerik:Location Latitude="41" Longitude="-100" />
              <telerik:Location Latitude="41" Longitude="-101" />
            </telerik:LocationCollection>
          </telerik:MapPolyline.Points>
        </telerik:MapPolyline>
      </telerik:InformationLayer>
 
      <telerik:InformationLayer Name="RectangleLayer" >
        <telerik:MapRectangle Width="10" Height="10" Location="40, -101" Fill="Green" telerik:RadDragAndDropManager.AllowDrag="True"  />
      </telerik:InformationLayer>
       
    </telerik:RadMap>

In code behind I wired up the DragInfo, DragQuery, DropInfo and DropQuery events at the user control level, but with the above markup the are never hit.

If I set the AllowDrag on the RectangleLayer and the AllowDrop on the RadMap, then the drag operation starts, but on drop I have the RectangleLayer as Source and the RadMap as destination. But I want to have the MapRectangle as Source and the Polyline as Destination.

EDIT: I figured out that drag an drop works fine on normal UIElements such as Ellipse or Rectangle. If I exchange my drag source MapRectangle with a Rectangle I can drag it. If I replace my MapPolyline with a Line I can drop the Rectangle to it. I can provide a sample if you tell me where to upload it. I tested this with Q1 2011.
While a Rectangle can replace the MapRectangle, the Line can not replace the MapPolyline, because it is not properly projected to geographical coordinats.

What am I doing wrong?

Greetings,  

Tobias.

7 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 25 Mar 2011, 09:41 AM
Hi Tobias Richling,

You can use the InformationLayer.GetItemsInLocation method to get the map polygon under the mouse pointer. I have attached a sample solution which uses this method.

Kind regards,
Andrey Murzov
the Telerik team
0
Simon Störmer
Top achievements
Rank 1
answered on 28 Mar 2011, 02:16 PM

Hi Andrey,

thanks for your answer, it helped me a lot! First I had problems to get your sample running in our environment, but this was due to the fact that we still use Q3 2010, where the GetItemsInLocation does not return any items. But I could work around that.

Now another issue arised. It is a little hard to explain, but I have a sample for you where I can reproduce the issue.

This is what I have:
I have a TourViewModel, that has a list of StationViewModel objects. The StationViewModel contains a Location instance. To extract a LocationCollection from the list of StationViewModel objects, the TourViewModel has an additional property Coordinates of type LocationCollection that extracts the Locations from the StationViewModels. My MainPageViewModel contains a list of StationViewModels and a list of TourViewModels.
In Xaml I have two InformationLayers: one for the station list from the MainPageViewModel, the other one for the tours. Stations are visualized by a rectangle, tours by MapPolylines, much as in your sample, expect that items are databound now.

This is the Problem:
I add a Tour from (41; -106) -> (43; -108) heading north west. Then I drag the point (44; -107) which is located to the north east from the last station. In the drop operation I figure out the dropped Point (the source) and the TourViewModel (the destination) and add a new StationsViewModel based on the dragged Location to the TourViewModel. The polyline updates itself, but by doing that the whole line changes its Longitudes decreasing them by one - that means the line moves southwards in the map. The same applies to Points (44, -109) and (44, -108).  Dragging (43; -109) or (42; -109) makes the polyline move to the west by incrementing the longitude by one. The Problem does not arise with all drops: (42, -108), (43, -107), (42, -106), (41, -105) work well.

I have attached a picture to illustrate the issue. Once again, I can provide an example solution that reproduces the issue.

I have attached a picture to illustrate the problem. The problem does not always happen. I am not sure wether I am doing something wrong or if this might be a bug.

Thanks for any help!

Kind regards,

Tobias.

0
Andrey
Telerik team
answered on 31 Mar 2011, 09:45 AM
Hello Tobias Richling,

I would appreciate if you provide us with a small solution which we could use to reproduce the problem.

Best wishes,
Andrey Murzov
the Telerik team
0
Simon Störmer
Top achievements
Rank 1
answered on 31 Mar 2011, 11:46 AM
Hi Andrey,

as I posted before I have an example, but I don't know where to upload it, because I can only attach pictures to my posts. Can you point me to the right direction, please?

Thank you,

Tobias.
0
Andrey
Telerik team
answered on 05 Apr 2011, 07:18 AM
Hello Tobias Richling,

It is possible to attach zip/rar file to the message.

Regards,
Andrey Murzov
the Telerik team
0
Simon Störmer
Top achievements
Rank 1
answered on 05 Apr 2011, 08:52 AM
Hi Andrey,

as I previously posted: I can only attach images (gif, jpg, jpeg and png files) to my messages. I even can not change the extension of my .rar file to jpg and upload it. Your server rejects the file due to wrong format (which is quiet right in this case :-) ). I attached a picutre of my upload box.

Please tell me where or how I can upload my example, because the issue is still very important to me. Or must I submit a support ticket?

Thank you,

Tobias.
0
Andrey
Telerik team
answered on 06 Apr 2011, 01:13 PM
Hi Tobias,

Sorry for the confusion -- indeed you cannot attach zip files in the public forums for security reasons. Could you open a formal support ticket and send us the example there?

Looking forward to your reply.


All the best,
Andrey Murzov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Map
Asked by
Simon Störmer
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Simon Störmer
Top achievements
Rank 1
Share this question
or