ExtJS 和谷歌地图
我正在尝试弄清楚 ExtJS 和 Google 地图的配合效果如何。我正在玩这个例子: http://dev .sencha.com/deploy/ext-4.0.0/examples/window/gmap.html
当我尝试找到地图时,我迷路了。我希望能够以编程方式更改缩放级别、绘制多边形并将点放置在地图上。
我一直在玩,所以我的代码与示例中的代码不一样。
我定义了一个表单面板并将地图嵌入其中。我有一个等待地图渲染的监听器:
listeners:{
afterrender: {
fn: setupWindow,
scope: this
}
}
然后,在 setupWindow 内我有这个:
gmap.setzoom(25);
mapBounds = new gmap.LatLngBounds(
new gmap.LatLng(responseJson.minY, responseJson.minX),
new gmap.LatLng(responseJson.maxY, responseJson.maxX)
);
但它在那里失败了。我做错了什么?
I'm trying to figure out how well ExtJS and Google Maps play together. I'm playing with this example: http://dev.sencha.com/deploy/ext-4.0.0/examples/window/gmap.html
I get lost when I try to address the map. I want to be able to programatically make changes to the zoom level, draw polygons and put points on the map.
I've been playing, so my code isn't the same as that in the example.
I've defined a form panel and I've embedded the map into it. I have a listener that waits for the map to be rendered:
listeners:{
afterrender: {
fn: setupWindow,
scope: this
}
}
Then, inside setupWindow I have this:
gmap.setzoom(25);
mapBounds = new gmap.LatLngBounds(
new gmap.LatLng(responseJson.minY, responseJson.minX),
new gmap.LatLng(responseJson.maxY, responseJson.maxX)
);
But it fails in there. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您在有问题的行之前调用
gmap.setZoom(25)
- 我假设gmap
是GMap2
的实例,如下所示:var gmap = new GMap2(...);
如果确实如此 - 那么
new gmap.LatLngBounds
或new gmap.LatLng
应该失败,因为两者都不是map
的函数(除非您将其添加到代码中)。您也许应该做的是:
编辑:澄清我的假设 - 从您尝试使用的 ExtJS 示例来看,您似乎正在尝试使用 API V2。
Since you are calling
gmap.setZoom(25)
in the line before the problematic one - I assumed thatgmap
is an instance ofGMap2
like so:var gmap = new GMap2(...);
If that is indeed the case - then
new gmap.LatLngBounds
ornew gmap.LatLng
should fail, because neither is a function ofmap
(unless you add it in your code).What you perhaps should do instead is:
EDIT: to clarify my assumption - from the ExtJS example that you are trying to use it seems that you are trying to go with API V2.
嗯...您正在尝试使用 Google Maps v3,而 ExtJS 示例是使用 GMap v2 构建的。
此外,正如 ZenMaster 指出的那样,您在尝试使用 GMap API 时遇到了一些混乱。 gmap变量从哪里来?在 v3 中使用
new google.maps.LatLng
,或者在 v2 中使用new GLatLng
。Well... you are attempting to use Google Maps v3, while the ExtJS example is built with GMap v2.
Additionally, like ZenMaster points out, you have some kind of mess in your attempt to use the GMap API. From where does the gmap variable come from? Either use
new google.maps.LatLng
in v3, ornew GLatLng
in v2.