使用谷歌地图Javascript

使用谷歌地图Javascript

本文介绍了使用谷歌地图Javascript API捏合缩放我自己的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个适合移动设备的网页,允许用户在<周围拖动< img> ; DIV> 。我使用 image.ontouchstart 方法工作了。现在我想做到这一点,以便用户在从iOS设备上查看时可以捏缩放(我目前正在从iPad本地浏览我的页面)。从我迄今为止所做的研究来看,似乎要采用Google Maps Javascript API。

I'm trying to create a mobile-friendly web page that will allow a user to drag an <img> around in a <div>. I've got this working using the image.ontouchstart method. Now I want to make it so the user can pinch-to-zoom when viewing this from an iOS device (I'm currently browsing to my page locally from my iPad). From the research I've done so far, it seems like the way to go is to use the Google Maps Javascript API.

我的问题是:

可以使用Google Maps Javascript API利用它在常规图像上的缩放缩放功能,而不仅仅是地图?

It is possible to use the Google Maps Javascript API to leverage it's pinch-to-zoom capabilities on a regular image, and not just a map?

我见过的每个例子都设置了 google.maps.Map object并指定纬度/经度。我只需要它可以用于任何给定的< img> 我放入我的< div> 。有谁知道这是否可能,或者知道我可以看到的任何例子?或者也许在常规图像上使用Google API比使用Google API更简单?

Every example I've seen sets up a google.maps.Map object and specifies a latitude/longitude. I just need it to work for any given <img> I place into my <div>. Does anyone know if this is possible, or know of any examples I could look at? Or maybe there is an easier way to do it on a regular image than using the Google API?

推荐答案

我相信你的选择是相当有限。但是,如果您可以容忍用户意识到地图位于您的图像下方(因为他们会在每次缩放后立即看到它),那么作为起点,请查看。

I believe your options are fairly limited. But if you can tolerate the user being aware that the map is underneath your image (because they'll see it for a split second after every zoom) then as a starting point, take a look at the answer at any technology to preview high definition photo, can zoom in and out like google maps.

它假设您从一个高清图像开始,并且您不想将整个图像完全加载到移动浏览器中,只是为了显示它完全缩小。放大时,将加载图像的适当元素(已分解为图块)。

It assumes you are starting with a high-definition image and that you don't want to load the whole image completely into the mobile browser just to display it completely zoomed out. As you zoom in, the appropriate elements of the image (which has been broken into tiles) will be loaded.

我不相信有一种简单的方法可以将API用作图像浏览器而不会将图像至少隐藏在图像叠加下的视图之外,但是这样会给你一个起点,至少看看是什么(也许不是)可能。

I do not believe that there is an easy way to use the API as an image browser without having the maps at least hidden out of view under the image overlay, but this will give you a starting point at least to see what is (and perhaps isn't) possible.

这篇关于使用谷歌地图Javascript API捏合缩放我自己的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 22:04