I have set a google maps (api v3) on div. Then I want to retrieve the map via the div.
Doing something like
theMap = $('.myDiv').theGoogleMap;
I can't find this simple info. Thank you for your help.
I have set a google maps (api v3) on div. Then I want to retrieve the map via the div.
Doing something like
theMap = $('.myDiv').theGoogleMap;
I can't find this simple info. Thank you for your help.
それはできません。グローバル変数を宣言して、その変数にマップ オブジェクトへの参照を保存できます。Google ドキュメントのサンプルを見てください。
var map;
function initialize() {
var myOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),
myOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
また、ここにJavascriptチュートリアルがあります:
API はその方向には機能しません。オブジェクトを作成するときは、JavaScript でオブジェクトへの参照を保持する必要があります。DOM 参照からマップ オブジェクトを検索することはできません。