Skip to content
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

ios使用scale后,调用高德地图,地图也会被缩掉,怎么解决? #54

Closed
Lee908105576 opened this issue May 30, 2016 · 11 comments

Comments

@Lee908105576
Copy link

No description provided.

@codekissyoung
Copy link

@Lee908105576 来点代码!!!

@shinyChen
Copy link

链家网手机版就遇到了这个问题,采取的方案是:对于地图进行zoom,比例为dpr。链接地址
scale当时没试过,理论上可以,但是是从中心点开始,需要transform-origin: 0 0 0。
还是zoom简单,不用写前缀,一个属性搞定。

@NextSeason
Copy link

@shinyChen 拖动的时候还是存在问题。

@shinyChen
Copy link

贴个链接吧,拖动的时候存在什么问题?拜托说得清楚点,要不怎么帮你解决问题

@changfuguo
Copy link

我用百度地图api也遇到这个问题,做法就是手动设置meta 设置为默认1,这个时候flexible就不会干预了

@pimkle
Copy link

pimkle commented Sep 26, 2016

@changfuguo 如果这样解决的话 这个页面其他的div 适配不会被打成原型吗?

@shiregg
Copy link

shiregg commented Nov 30, 2016

ios中,这是iphone6

echarts整个都缩小了一半。

@songsiqi
Copy link

可以手动设置一下 viewport 不缩放, <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"> 就可以了。但是会有个问题,1px 的线不细了

@94dreamer
Copy link

如何手动设置

@94dreamer
Copy link

@shinyChen 手机sacle之后 地图变模糊

@66beta
Copy link

66beta commented Nov 1, 2017

有个简单粗暴的办法:
1、在当前页面(组件),重置下meta标签和dpr

mounted () {
    this.$nextTick(function () {
      const dpr = document.documentElement.getAttribute('data-dpr')
      if (dpr > 1) {
        window.tempViewport = document.querySelector('meta[name="viewport"]').getAttribute('content')
        document.querySelector('meta[name="viewport"]').setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no')
        window.tempDpr = dpr
        document.documentElement.setAttribute('data-dpr', 1)
      }
    })
  //.......
}

2、离开页面的时候,再还原回去:

beforeRouteLeave (to, from, next) {
    if (window.tempViewport) {
      document.querySelector('meta[name="viewport"]').setAttribute('content', window.tempViewport)
      delete window.tempViewport
    }
    if (window.tempDpr) {
      document.documentElement.setAttribute('data-dpr', window.tempDpr)
      delete window.tempDpr
    }
    next()
}

3、覆盖地图组件的样式

如果不用vue-router的话,可以用mixins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants