-
Notifications
You must be signed in to change notification settings - Fork 81
Added new kb article map-custom-image #2619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ntacheva
merged 8 commits into
master
from
new-kb-map-custom-image-3e6ca22524814ef5aa64424b27ab9e60
Dec 13, 2024
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
19dcfda
Added new kb article map-custom-image
50fec48
Update knowledge-base/map-custom-image.md
ntacheva c511ce6
Update knowledge-base/map-custom-image.md
ntacheva ff25496
Update knowledge-base/map-custom-image.md
ntacheva ff20c37
Update knowledge-base/map-custom-image.md
ntacheva 38fabc7
Update knowledge-base/map-custom-image.md
ntacheva 53e6968
Update knowledge-base/map-custom-image.md
ntacheva 7c1e319
chore(Map): address feedback
ntacheva File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| --- | ||
| title: Use a Custom Image as a Map in the Map Component | ||
| description: Learn how to integrate a custom image with the Blazor Map component for displaying markers on static images, such as building layouts. | ||
| type: how-to | ||
| page_title: How to Use a Custom Image with Blazor Map for Marker Placement | ||
| slug: map-kb-custom-image | ||
| tags: map, blazor, custom, image, markers | ||
| res_type: kb | ||
| ticketid: 1652767 | ||
| --- | ||
|
|
||
| ## Environment | ||
|
|
||
| <table> | ||
| <tbody> | ||
| <tr> | ||
| <td>Product</td> | ||
| <td>Map for Blazor</td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
ntacheva marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Description | ||
|
|
||
| This knowledge base article answers the following questions: | ||
|
|
||
| - How can I set a background image for the Blazor Map component? | ||
| - Is it possible to overlay markers on a static image in Blazor Map? | ||
| - Can I use a custom floor plan as a map in Blazor? | ||
|
|
||
| ## Solution | ||
|
|
||
| The solution depends on whether you want to show a static Map or if you want to support panning and zooming functionalities. This knowledge base shows the first option: | ||
|
|
||
| * [Static Map](#static-map) | ||
| * [Pannable and Zoomable Map](#pannable-and-zoomable-map) | ||
|
|
||
| ### Static Map | ||
|
|
||
| This method is ideal when using the Map in a static context without the need for dynamic panning and zooming. In this case, you may use CSS to target the wrapping element of the component and set your image as a background image. | ||
|
|
||
| >caption Use custom image as a map | ||
|
|
||
| ````CSHTML | ||
| <style> | ||
| .custom-map{ | ||
ntacheva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| background-image: url(https://d585tldpucybw.cloudfront.net/sfimages/default-source/productsimages/telerik-ui-for-blazor/blazor-header-ninja.svg?sfvrsn=41f12bb3_3); | ||
| position: relative; | ||
| } | ||
|
|
||
| .custom-map .k-map-controls{ | ||
ntacheva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| display:none; | ||
| } | ||
| </style> | ||
|
|
||
| <TelerikMap Class="custom-map" Zoomable="false" Pannable="false" Width="515px" Height="440px"> | ||
| <MapLayers> | ||
| <MapLayer Type="@MapLayersType.Marker" | ||
| Data="@MarkerData" | ||
| LocationField="@nameof(MarkerModel.LatLng)" | ||
| TitleField="@nameof(MarkerModel.Title)"> | ||
| </MapLayer> | ||
| </MapLayers> | ||
| </TelerikMap> | ||
|
|
||
| @code { | ||
| public List<MarkerModel> MarkerData { get; set; } = new List<MarkerModel>() | ||
| { | ||
| new MarkerModel() | ||
| { | ||
| LatLng = new double[] {-15.014573802798589, -36.825833916664131 }, | ||
| Title = "Marker 1" | ||
| }, | ||
| new MarkerModel() | ||
| { | ||
| LatLng = new double[] {28.85837817460806, 25.92807233333588 }, | ||
| Title = "Marker 2" | ||
| } | ||
| }; | ||
|
|
||
| public class MarkerModel | ||
| { | ||
| public double[] LatLng { get; set; } | ||
| public string Title { get; set; } | ||
| } | ||
| } | ||
| ```` | ||
|
|
||
| ### Pannable and Zoomable Map | ||
|
|
||
| If you want to support panning and zooming the custom image in the Map, you will need to mimic the default Map behavior targeting the [Tile layer]({%slug components/map/layers/tile%}). For that purpose, divide your image into small pieces - separate images that build up the whole picture and serve them to the Map as tiles following the Tile layer specifics. | ||
ntacheva marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## See Also | ||
|
|
||
| * [Map Overview]({%slug components/map/overview%}) | ||
| * [Markers in Map for Blazor]({%slug components/map/layers/marker%}) | ||
| * [Tile Layer in Map for Blazor]({%slug components/map/layers/tile%}) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.