Drag and Drop on the map

8 posts, 0 answers
  1. Simon Störmer
    Simon Störmer avatar
    31 posts
    Member since:
    Oct 2012

    Posted 23 Mar 2011 Link to this post

    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.
  2. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 25 Mar 2011 Link to this post

    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
  3. DevCraft banner
  4. Simon Störmer
    Simon Störmer avatar
    31 posts
    Member since:
    Oct 2012

    Posted 28 Mar 2011 Link to this post

    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.

  5. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 31 Mar 2011 Link to this post

    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
  6. Simon Störmer
    Simon Störmer avatar
    31 posts
    Member since:
    Oct 2012

    Posted 31 Mar 2011 Link to this post

    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.
  7. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 05 Apr 2011 Link to this post

    Hello Tobias Richling,

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

    Regards,
    Andrey Murzov
    the Telerik team
  8. Simon Störmer
    Simon Störmer avatar
    31 posts
    Member since:
    Oct 2012

    Posted 05 Apr 2011 Link to this post

    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.
  9. Andrey
    Admin
    Andrey avatar
    1681 posts

    Posted 06 Apr 2011 Link to this post

    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
Back to Top
DevCraft banner