English 中文(简体)
页: 1
原标题:Google Maps — How To Finesse The Viewport Of A Geocoded Address

I m 执行谷歌地图,使之成为一个新项目,一页应归还加拿大的大型(100%*)地图。 I m还利用地理编码确定将要通过该地图的支线。

该法典:

var myLatlng = new google.maps.LatLng(37.775, -122.4183333);
        var myOptions ={
            zoom: 5,
            center: myLatlng,
            mapTypeId: google.maps.MapTypeId.TERRAIN
        }

        map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

        var address = "Canada";
        var geocoder = new google.maps.Geocoder(address);
        geocoder.geocode( {  address : address}, function(results, status) {
            if (status == google.maps.GeocoderStatus.OK) {
                //map.setCenter(results[0].geometry.location);
                            //The above was too far north
                map.fitBounds(results[0].geometry.viewport);
                map.setZoom(5);
            } else {
                alert("Geocode was not successful for the following reason: " + status);
            }
        });

它的工作很出色,但“距离左边太远”。 基本上,它切断了大多数海洋省份。 这方面的一个例子是:

http://50.28.69.176/~sequoia/locations.php

任何人都知道如何对此进行罚款,以便该国能够更集中地看待这一问题?

感谢任何帮助。

最佳回答

我建议,不要在每一页装上地勤,而只读到你想要的正确的,并加以储存。

如果你仍然想坚持这一办法,你可以使用<条码>植被()法,在<条码>上使用

这样,你就可以呼吁

map.fitBounds(results[0].geometry.viewport.getCenter())
map.setZoom(5)
问题回答

暂无回答




相关问题
Selecting Links in Google Maps InfoWindows w/ jQuery

In my web app, I am using jQuery to select all the links on the page and intercept where they go to so that I can switch to a different part of the page with AJAX. The problem is that some of these ...

Add custom control to Subgurim Maps

Is it possible to add a custom control to the GMap control in the Subgurim library? I see that I can add a GControl with the GMap.AddControl method. I tried to create a custom GControl by ...

Changing the value in a map in Groovy

This is about a very basic program I m writing in Groovy. I have defined a map inside a method: def addItem() { print("Enter the item name: ") def itemName = reader.readLine() print(...

Best way to store and retrieve this..?

I ve been trying all night, and talk of maps, arrays, vectors and hash_maps have filled my head. im just confused now. i posted a previous question here: C++ map really slow? problem was fixed but it ...

热门标签