Created
August 7, 2023 09:23
-
-
Save tianrking/749ce12f38aecbbee118f771ba63cf34 to your computer and use it in GitHub Desktop.
Display map Pyside6& AMAP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PySide6.QtWidgets import QApplication, QMainWindow | |
from PySide6.QtWebEngineWidgets import QWebEngineView | |
class WebMap(QWebEngineView): | |
def __init__(self): | |
super().__init__() | |
self.setHtml(f''' | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> | |
<style type="text/css"> | |
body, html,#allmap {{width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}} | |
</style> | |
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=YOUR_API_KEY"></script> | |
</head> | |
<body> | |
<div id="allmap"></div> | |
</body> | |
</html> | |
<script type="text/javascript"> | |
var map = new AMap.Map('allmap', {{ | |
resizeEnable: true, | |
center: [116.397428, 39.90923], | |
zoom: 13 | |
}}); | |
</script> | |
''') | |
app = QApplication(sys.argv) | |
window = QMainWindow() | |
webmap = WebMap() | |
window.setCentralWidget(webmap) | |
window.show() | |
sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment