【发布时间】:2018-03-01 13:50:11
【问题描述】:
我需要你的帮助。 从 Python IDLE 控制台执行这段代码,我有一个错误:
"TypeError: 'undefined' is not a function (evaluating 'this.D.bind(this)')"
并且标记在地图上不可见。
我在浏览器中执行 html 代码并且没有错误。地图和标记都很完美。
发现错误在marker.js文件中:http://maps.google.com/maps-api-v3/api/js/32/2/intl/es_419/marker.js
# -*- coding: utf-8 -*-
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
html= \
"""
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 8
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDfBy5lpFyQzq7pRpKEBeg7jaXH5hnHul8&callback=initMap"
async defer></script>
</body>
</html>
"""
class Window(QWidget):
def __init__(self):
super(Window, self).__init__()
self.view = QWebView(self)
self.setupInspector()
self.splitter = QSplitter(self)
self.splitter.setOrientation(Qt.Vertical)
layout = QVBoxLayout(self)
layout.setMargin(0)
layout.addWidget(self.splitter)
self.splitter.addWidget(self.view)
self.splitter.addWidget(self.webInspector)
def setupInspector(self):
page = self.view.page()
page.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
self.webInspector = QWebInspector(self)
self.webInspector.setPage(page)
shortcut = QShortcut(self)
shortcut.setKey(Qt.Key_F12)
shortcut.activated.connect(self.toggleInspector)
self.webInspector.setVisible(False)
def toggleInspector(self):
self.webInspector.setVisible(not self.webInspector.isVisible())
def main():
app = QApplication(sys.argv)
window = Window()
window.show()
window.view.setHtml(html)
app.exec_()
if __name__ == "__main__":
main()
【问题讨论】:
标签: python google-maps marker