简体   繁体   English

可扩展的谷歌地图覆盖

[英]Scalable google maps overlay

Is it possible to add an image overlay to a google map that scales as the user zooms?是否可以将图像叠加添加到随着用户缩放而缩放的谷歌地图?

My current code works like this:我当前的代码是这样工作的:

var map = new GMap2(document.getElementById("gMap"));

var customIcon = new GIcon();
customIcon.iconSize = new GSize(100, 100);
customIcon.image = "/images/image.png";

map.addOverlay(new GMarker(new GLatLng(50, 50), { icon:customIcon }));

However, this adds an overlay that maintains the same size as the user zooms in and out (it is acts as a UI element like the sidebar zoom control).但是,这会添加一个叠加层,该叠加层在用户放大和缩小时保持相同的大小(它充当类似于侧边栏缩放控件的 UI 元素)。

There is a zoomend event, fired when the map reaches a new zoom level.有一个 zoomend 事件,当地图达到新的缩放级别时会触发。 The event handler receives the previous and the new zoom level as arguments.事件处理程序接收前一个和新的缩放级别作为参数。

http://code.google.com/apis/maps/documentation/reference.html#Events_GMap http://code.google.com/apis/maps/documentation/reference.html#Events_GMap

You might want to check out openlayers你可能想看看openlayers

It's a very capable Javascript API - it supports a bunch of back ends, allowing you to transparently switch between, say, Google Map tiles and Yahoo Map tiles.这是一个功能非常强大的 Javascript API - 它支持一堆后端,允许您在 Google 地图图块和雅虎地图图块之间透明地切换。

Well after messing around trying to scale it myself for a little bit I found a helper called EInserts which I'm going to check out.好吧,在尝试自己扩展一下之后,我找到了一个名为EInserts的助手,我将要查看它。

Addition:添加:

Okay EInserts is about the coolest thing ever.好吧,EInserts 是有史以来最酷的东西。 It even has a method to allow you to drag the image and place it in development mode for easy lining up.它甚至有一种方法可以让您拖动图像并将其置于开发模式以方便排列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM