uwp MapControl, how can I add search box to the control?

SmilingMoon 981 Reputation points
2021-03-17T03:40:28.567+00:00

I like a user to select a location with map, MapControl, in uwp app.
I couldn't find a way to add search box to the map control like Windows Maps app like below.

78526-2021-03-16-20-39-35-window.png

Is it even possible?

Universal Windows Platform (UWP)
Windows Maps
Windows Maps
A Microsoft app that provides voice navigation and turn-by-turn driving, transit, and walking directions.
245 questions
0 comments No comments
{count} votes

Accepted answer
  1. Duncan Lawler - MSFT 486 Reputation points Microsoft Employee
    2021-03-17T16:34:00.987+00:00

    There is no direct Search UI as most apps will want to customize what the UI looks like, but you can just place a standard XAML text box anywhere you like, and in the handler for the search button, call the Location finder API here:
    https://learn.microsoft.com/en-us/uwp/api/windows.services.maps.maplocationfinder?view=winrt-19041

    It will return search results that you can then display on the map.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. AryaDing-MSFT 2,841 Reputation points
    2021-03-17T08:26:01.053+00:00

    You could add SearchBox to MapControl directly.

    As follows:

    <Maps:MapControl x:Name="MapControl1"                             
                                 Height="300"  
                                 Width="500"                              
           ZoomInteractionMode="GestureAndControl"  
           TiltInteractionMode="GestureAndControl"          
           MapServiceToken="..">  
      
                    <SearchBox Width="150" Background="Transparent"/>  
      
    </Maps:MapControl>  
    

    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.