var
map = new google.maps.Map($mapElement[0], mapOptions);
console.log($mapElement[0]);
google.maps.event.addListener(map, 'zoom_changed', function () {
var zoomLevel = map.getZoom();
logger.debug('zoom_changed to level: ' + zoomLevel);
}
星期一, 1月 25, 2016
[GoogleMap] 如何監聽zoom變更的控制
如何監聽zoom變更的控制
星期一, 10月 05, 2015
[GoogleMap] 如何動態載入Googlemap API
最近試著使用google map的離線api,目前google可以找到不同版本的,目前測試是3.8.2。
使用document.createElement的方法,console會噴以下這個錯誤
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
如果是在頁面直接透過script標籤引入mapapi.js是沒什麼大問題的!!
不過由於要實作讓使用者切換線上與離線地圖就發現了很扯的bug,
var jsTag = '<' + 'script src="http://localhost:8080/js/libs/offlinemap/google/mapapi.js"' +
' type="text/javascript"><' + '/script>';
document.write(jsTag);
使用document.createElement的方法,console會噴以下這個錯誤
Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
var element = document.createElement("script");
element.src = "js/libs/offlinemap/google/mapapi.js";
element.type = "text/javascript";
document.getElementsByTagName("head")[0].appendChild(element);
成功的方法
訂閱:
意見 (Atom)