开发者

change map size on click

开发者_JAVA技巧How can I set it up so when a user clicks the submit button, the map will resize itself to fit directions as it is on yelp maps when finding directions?

Thanks


Well, without much information in your question, just add a style modification in your map direction handler. In it's simplest form: But without knowing more about your particular setup, I can't do much more.

HTML:

<FORM onSubmit="findDirections()">

JavaScript:

function findDirections() {
    // Change map width
    document.getElementsById("directions_map").style.width = "600px";

    // Do google maps lookup, etc
}


Do you mean how to set center and zoom of map to have direction fit in such a view? If so, you can obtain points of this direction, add them to create LatLngBounds (using the extend method) and use Map.fitBounds with prepared bounds as parameter.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜