3

Currently I am working on a Packaged Chrome app which incorporates a Google Map. I am however unable to zoom using pinch. Also 'normal' zoom on a webpage doesn't work.

All pages (and maps) I use are zoomable with pinches if I open them in Google Chrome directly, but I don't seem to get it working in a packages app. Any ideas? Might this be a permissions or WindowOptions problem?

Working on Mac 10.11.3. Chrome version 48.0.2564.116

Simple example (dropbox link): zoomtest

manifest.json

{
    "name": "Zoom test",
    "version": "0.1",
    "manifest_version": 2,
    "app": {
        "background": {
            "scripts": ["background.js"]
        }
    }
}

background.js

chrome.app.runtime.onLaunched.addListener(function() {
    chrome.app.window.create('index.html', {
        innerBounds: { width: 800, height: 600 },
        state: 'normal'
    });
});

index.html

<html>
<head>
<style>
p {
    width: 400px;
}
</style>
</head>
<body>
<p>This page is zoomable in Google Chrome if opened directly,
but not if run as an app.</p>

</body>
</html>
sy1vain
  • 41
  • 4
  • Show us how you embed the map. – Xan Mar 04 '16 at 12:39
  • I also have it with non-maps pages. When opening them directly in Chrome I can zoom on the HTML page with pinches. But in a Chrome app I can't. Is there some setting I'm missing? – sy1vain Mar 17 '16 at 21:46
  • Perhaps. Still, show a minimal example. – Xan Mar 17 '16 at 21:46
  • [link](https://www.dropbox.com/s/uwgl1mmxxn0zsvj/zoomtest.zip?dl=0) I will try to post the code here as well – sy1vain Mar 19 '16 at 19:32
  • Well, without running, that's simply [not going to work](https://developer.chrome.com/apps/contentSecurityPolicy). Has nothing to do with zoom - it just won't work _at all_. – Xan Mar 19 '16 at 19:34
  • Basically, can you provide an example of zoom not working _without_ any external content? – Xan Mar 19 '16 at 19:47
  • The above example does work. Google maps loads just fine because of the sandbox settings, which is preferred, I think. I will change the example to not use maps for clarity. – sy1vain Mar 21 '16 at 08:25
  • Now with a clear minimal example I can upvote the question; unfortunately, I don't have an answer for this. – Xan Mar 21 '16 at 08:30

1 Answers1

1

I managed to fix it by using the following function:

function mapTouchFix(){
  if("ontouchstart" in window || window.DocumentTouch && document instanceof DocumentTouch){
    navigator = navigator || {};
    if(navigator.platform!='MacIntel'){
      navigator.msMaxTouchPoints = navigator.msMaxTouchPoints || 2;
    }
  }
}

Apparently this spoofed Chrome / Google maps to enable the pinch gestures

sy1vain
  • 41
  • 4