开发者

ExtJS and Google Maps

开发者 https://www.devze.com 2023-04-02 09:23 出处:网络
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'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 polygon开发者_JAVA百科s 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?


Since you are calling gmap.setZoom(25) in the line before the problematic one - I assumed that gmap is an instance of GMap2 like so:

var gmap = new GMap2(...);

If that is indeed the case - then new gmap.LatLngBounds or new gmap.LatLng should fail, because neither is a function of map (unless you add it in your code).

What you perhaps should do instead is:

mapBounds = new GLatLngBounds(
                    new GLatLng(responseJson.minY, responseJson.minX),
                    new GLatLng(responseJson.maxY, responseJson.maxX)
                );

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.


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, or new GLatLng in v2.

0

精彩评论

暂无评论...
验证码 换一张
取 消