JSFiddle - React, Tailwind, and code Playground
by 亮 薛
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{width: 100%;height: 100%;margin:0;font-family:"微软雅黑";}
#allmap{height:500px;width:100%;}
#r-result{width:100%; font-size:14px;}
</style>
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=您的密钥"></script>
<title>城市名定位</title>
</head>
<body>
<div id="allmap"></div>
<div id="r-result">
站点编号: <input id="siteId" type="text" style="width:100px; margin-right:10px;" value="1419" />
经度: <input id="longitude" type="text" style="width:100px; margin-right:10px;" value="121.414136" />
纬度: <input id="latitude" type="text" style="width:100px; margin-right:10px;" value="31.244726"/>
<input type="button" value="查询" onclick="theLocation()" />
</div>
<div id="sql">
</div>
</body>
</html>
<script type="text/javascript">
// 百度地图API功能
var map = new BMap.Map("allmap");
map.centerAndZoom(new BMap.Point(116.331398,39.897445),11);
map.enableScrollWheelZoom(true);
// 用经纬度设置地图中心点
function theLocation(){
if(document.getElementById("longitude").value != "" && document.getElementById("latitude").value != ""){
map.clearOverlays();
var new_point = new BMap.Point(document.getElementById("longitude").value,document.getElementById("latitude").value);
var marker = new BMap.Marker(new_point); // 创建标注
map.addOverlay(marker); // 将标注添加到地图中
map.panTo(new_point);
}
}
var id = 1001280;
function showInfo(e){
id++;
var str = 'INSERT INTO `xqcxdb`.`tt_site_point`(`id`, `site_id`, `longitude`, `latitude`, `geo_hash`, `sort`, `point_type`, `remark`, `created_time`, `updated_time`, `creator`, `updater`) VALUES (' + id + ', ' + document.getElementById("siteId").value + ', ' + e.point.lng + ', ' + e.point.lat + ', \'123\', 1, 1, NULL, NULL, NULL, NULL, NULL);'
document.getElementById('sql').innerHTML =...