title: UIWebView, Zoom & elementFromPoint
body: <p>In a <code>UIWebView</code> I need to access properties of the DOM element (from a SVG graph) when I longTap on it. To do so, I've added a <code>UILongPressGestureRecognizer</code> as following :</p>
  
  <pre><code>UILongPressGestureRecognizer* longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action: @selector(longPress:)];
  [self.webView addGestureRecognizer: longPress];
  </code></pre>
  
  <p>When I longPress on the view, the handler get called from which I call a JS function  :</p>
  
  <pre><code>- (void) longPress: (UIGestureRecognizer *) gesture {
      CGPoint curCoords = [gesture locationInView:self.webView];
  
      if (!CGPointEqualToPoint(curCoords, self.lastLongPress)) {
          self.lastLongPress = curCoords;
          [self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"longPress(%f, %f)", curCoords.x, curCoords.y]];
      }
  }
  </code></pre>
  
  <p>This is my JS handler :</p>
  
  <pre><code>function longPress(x, y) {
  
      x = x + window.pageXOffset;
      y = y + window.pageYOffset;
  
      var element = svgDocument.elementFromPoint(x, y);                                                                                                                                                                                                                           
      alert(element.localName + ' ' + x + ' ' + y + ' ' + window.innerWidth + ' ' +  window.innerHeight);
  }
  </code></pre>
  
  <p>However it appears that <code>UIWebView</code> coordinates are != from the DOM coordinates (where I click does not correspond to the localName shown in the alert). I've managed to figure out that there is +/- a 1.4 factor between <code>UIWebView</code> coordinates &amp; JS ones (by clicking in the lower-right hand side of the screen and comparing these values with <code>window.innder{Width,Height}</code>.</p>
  
  <p>My guess was that <code>UIWebView</code> might apply a default Zoom ratio initially, but I can't find what this values corresponds to.</p>
  
  <p>Moreover, I'll also need a way to make this work when the user actually zooms/moves the page.</p>
  
  <p>Does anybody knows what I'm doing wrong ?</p>
  
  <p>Thanks,</p>