In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to solve the problem of map point click offset dislocation after the overall use of transform scale on the page, I believe that many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Recently, css3 transform:scale () was used in the visualization project to encapsulate a component to make the page shrink or enlarge the adaptive screen.
Js file:
Import React, {useState, useEffect} from 'react';import {useDebounceFn} from' ahooks';import styles from'. / index.module.less'; export default ({width, height, children}) = > {const getScale = () = > {const x = window.innerWidth / width; const y = window.innerHeight / height; return {x, y}; console.log (width, height, 'props'); const [scale, setScale] = useState (getScale ()) Const {run: handleScale} = useDebounceFn (() = > {const s = getScale (); setScale (s);}, {wait: 500,}); useEffect (() = > {window.addEventListener ('resize', handleScale);}, []); useEffect () = > {console.log (' current scale', scale);}, [scale]); return ({children}) }
Css file:
.scale-box {position: absolute; top: 0; left: 50%; transform-origin: 0; transition: 0.3s;}
Then found that the use of transform:scale () zoom will lead to Amap's point position when clicking will occur point offset dislocation situation, found a lot of ways to solve the problem with iframe
Encapsulate a separate component of the map and use iframe to introduce this component
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.