How to rotate the Azure Map around custom point

Daniels Danilins 1 Reputation point
2021-11-01T06:41:08.407+00:00

Is it possible to rotate the map using API around any custom point, not just the center? I can do this with fingers but didn't find a way to do this with API.
I have tried setting centerOffset, but it just moves the map.

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

2 answers

Sort by: Most helpful
  1. rbrundritt 18,686 Reputation points Microsoft Employee
    2021-11-01T17:15:18.043+00:00

    There is no built in option for this, nor have I seen any such feature in any other map platform. That said, here is an approach I would take to try and accomplish this;

    1. Calculate distance and heading from your desired rotation point and the center of the map.
    2. Follow this animation example: https://azuremapscodesamples.azurewebsites.net/?sample=Simple%20Symbol%20Animation but use the rotation point, distance and heading offset to calculate a new center for the map, and set the camera rather than the position of a feature. The following math functions will help:
    0 comments No comments

  2. Daniels Danilins 1 Reputation point
    2021-11-11T13:45:46.52+00:00

    I have done something simpler.

    HTML:

    <div id="mapWrap">
        <div id='myMap' ></div>
    </div>
    

    CSS:

    #myMap {
      height: 400px;
      width: 50vw;
    }
    #mapWrap {
      height: 200px;
      overflow: hidden;
    }
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.