Map callout rotates with map __ map

Source: Internet
Author: User
Parking lot Map Add parking number rotate function with map rotation

Now the interactivity on the mobile internet is very strong and requires a 360 degree rotation of the map. But when the map is rotated at 360 degrees, there is a problem, that is, the map to choose 180 degrees, the map above the text is also rotated 180 degrees, this time the word is the reverse, although logically speaking is correct, but from a human point of view, I'm going to rotate the map 180 degrees. Do I have to tilt my head to see the above words? That's definitely not going to work.

We have two solutions for this problem:
* Callout text does not rotate
is to allow you to rotate the map, my map above the callout is always maintained. The solution is simple. However, the use of this method needs to satisfy a premise, that is: the map annotation to the map area is not required. For example, the annotations added above the elements of a large area can be handled in this way. What will happen to small regional elements? We use parking spaces and parking spaces on the map as an example to illustrate. Parking spaces on the map are a rectangular element with a small area. His parking number tagging requires that the text not exceed the rectangular area and display as large as possible, which means that the text is to be written along the length of the rectangular box. If the map is rotated and the callout does not turn, there will be problems.
* Callout Text Rotates the map
This callout text is selected with the map and the rotation is not mechanical along his choice. We do a mathematical analysis of the rotation of the text, we will find that the text rotation in the [90,270] within the range of text is inverted, so only need to select the angle of the text within the range of the region to do a simple mathematical treatment for him to meet the requirements. The processing logic is also very simple, that is, the rotation angle within [90,270] This range allows him to choose more than 180 degrees.

Gets the rotation angle
var rotation = (Feature.get (' rotation ') *1+newrotation*1)%6.2831852;
if (rotation >= 1.5707963 &&  rotation <= 4.7123889) {
  rotation = (rotation + 3.1415926)%6.2831852;< c5/>}


Map North Direction


Mechanical rotation


To add a rotation after a mathematical process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.