Show text on ploygon

Balasaheb Molawade 136 Reputation points
2023-12-13T09:40:59.6333333+00:00

Hi Team,

 We have a requirement from the customer to provide an option to plot the polygon and then allow the ability to assign a name, with the name always displayed at the center, something like the example below.

Anotation

Is there any way or sample code available to fulfill this requirement.

 Thanks!

 

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
606 questions
0 comments No comments
{count} votes

Accepted answer
  1. rbrundritt 15,546 Reputation points Microsoft Employee
    2023-12-13T16:00:00.1233333+00:00

    In Bing Maps you can use the math library to calculate the centroid of the polygon and use a pushpin to add a label. Here is a sample: https://samples.bingmapsportal.com/?search=polygon&sample=polygon-with-label

    In Azure Maps there are a couple of ways to do this. The symbol layer supports polygons, so you can simply attached a data source of polygons to that layer and create labels, however the position may not be ideal. Alternatively, you can calculate a label position similar to the Bing Maps sample and create a data source of points for each label. Here are some samples:

    https://samples.azuremaps.com/?sample=polygon-labels---symbol-layer

    https://samples.azuremaps.com/?sample=polygon-labels---calculated

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful