Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
155
Create Marker on click
posted

Hi,

I've seen the example in your website about markers but it's example with preload markers, and I would know if it's possible to create a marker on the coordonate where I click with the mouse (And clear all markers with button) ?

I've searched but I don't find any example

Thanks and sorry if my question is a little dumb !

Parents
No Data
Reply
  • 28925
    Offline posted

    Hello Ezekief,

    You can create a SymbolElement and place it at the location where the end-user clicks. To start, handle the map's MapMouseLeftButtonDown event and track the coordinates where clicked.

    This was previously discussed here:
    https://www.infragistics.com/community/forums/f/retired-products-and-controls/36373/determine-latitude-and-longitude-on-map-click-event/211645#211645

    Full code example: Placing markers on-click

     private void XamMap1_MapMouseLeftButtonDown(object sender, MapMouseButtonEventArgs e)
            {
                Point mousePosition = e.Position;
                Point mapPosition = xamMap1.Viewport.RootCanvas.RenderTransform.Inverse.Transform(mousePosition);

                SymbolElement element = new SymbolElement()
                { SymbolOrigin = mapPosition, Caption = "Marker", SymbolType = MapSymbolType.Diamond, SymbolSize = 10 };

                xamMap1.Layers[0].Elements.Add(element);
                element.ZIndex = 0;
            }

    Let me know if you have any questions regarding this matter.

Children
No Data