You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
105 lines
4.2 KiB
105 lines
4.2 KiB
|
|
|
|
var OrgId = JSON.parse(window.sessionStorage.getItem("userInfo")).OrgID;
|
|
//var OrgId = "9668E5E778854EC3939246D6B6A9EFC1";//kashi
|
|
|
|
//根据当前登陆人机构ID获取机构所在经纬度
|
|
$.ajax({
|
|
type: "post",
|
|
url: "../../ashx/FireOrgHandler.ashx",
|
|
data: { Action: "getFireOrgName", ID: OrgId },
|
|
dataType: "json",
|
|
success: function (result) {
|
|
//initMap(result.data.LON, result.data.LAT, result.data.CITY);
|
|
//initIco();
|
|
console.log(result);
|
|
var map = new AMap.Map('container', {
|
|
resizeEnable: true, //是否监控地图容器尺寸变化
|
|
zoom: 13, //初始化地图层级
|
|
center: [result.data.LON, result.data.LAT] //初始化地图中心点
|
|
//center: [117.12783, 36.674013] //初始化地图中心点
|
|
//,mapStyle: 'amap://styles/954adf1b935afaab14d259c98ead7292' //设置地图的显示样式
|
|
});
|
|
|
|
|
|
//map.plugin('AMap.Geolocation', function () {
|
|
|
|
var myIcon = new AMap.Icon({ size: new AMap.Size(30, 40), image: 'http://xzcamp.xfzn365.com//images/xfz1.png', imageSize: new AMap.Size(30, 40) });
|
|
var marker = new AMap.Marker({
|
|
//position: new AMap.LngLat(94.40887, 29.580462),
|
|
position: new AMap.LngLat(result.data.LON, result.data.LAT),
|
|
title: result.data.ORG_NAME,
|
|
icon: myIcon
|
|
}); // 创建标注
|
|
map.add(marker);
|
|
|
|
//geolocation.getCurrentPosition(); //精准定位
|
|
//// geolocation.getCityInfo(); //定位到城市
|
|
//AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息
|
|
//AMap.event.addListener(geolocation, 'error', onError); //返回定位出错信息
|
|
/* });*/
|
|
|
|
|
|
//解析定位结果
|
|
function onComplete(data) {
|
|
if (data.status == 1) {
|
|
console.log("定位成功啦");
|
|
$("#addressInput").val(data.formattedAddress);
|
|
sessionStorage.setItem("dingWei-lng", data.position.getLng());
|
|
sessionStorage.setItem("dingWei-lat", data.position.getLat());
|
|
}
|
|
var str = [];
|
|
str.push('经度:' + data.position.getLng());
|
|
str.push('纬度:' + data.position.getLat());
|
|
str.push('是否经过偏移:' + (data.isConverted ? '是' : '否'));
|
|
console.log(str.join('\n'));
|
|
|
|
$("#districtName").val(data.position.getLng() + "," + data.position.getLat());
|
|
$('#LON', window.parent.frames[0].document).val(data.position.getLng());// 赋值
|
|
$('#LAT', window.parent.frames[0].document).val(data.position.getLat());// 赋值
|
|
$('#COORDINATE_TYPE', window.parent.frames[0].document).val(1);// 赋值
|
|
}
|
|
function onError() {
|
|
var str = [];
|
|
str.push('定位失败');
|
|
console.log(str.join('\n'));
|
|
}
|
|
|
|
|
|
var placeSearch = "";
|
|
var marker = null;
|
|
AMap.service(["AMap.PlaceSearch"], function () {
|
|
//构造地点查询类
|
|
placeSearch = new AMap.PlaceSearch({
|
|
map: map, // 展现结果的地图实例
|
|
autoFitView: true // 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围
|
|
});
|
|
//关键字查询
|
|
|
|
});
|
|
$("#search").click(function () {
|
|
placeSearch.search($("#poiname").val());
|
|
});
|
|
|
|
|
|
map.on("click", function (e) {
|
|
|
|
if (marker != null) {
|
|
map.remove(marker);
|
|
}
|
|
marker = new AMap.Marker({
|
|
position: new AMap.LngLat(e.lnglat.getLng(), e.lnglat.getLat()),
|
|
offset: new AMap.Pixel(-13, -30)
|
|
});
|
|
map.add(marker);
|
|
var wgs84Coordinate = gcj02towgs84(e.lnglat.getLng(), e.lnglat.getLat());
|
|
$("#districtName").val(wgs84Coordinate[0] + "," + wgs84Coordinate[1]);
|
|
$('#LON', window.parent.frames[0].document).val(wgs84Coordinate[0]);// 赋值
|
|
$('#LAT', window.parent.frames[0].document).val(wgs84Coordinate[1]);// 赋值
|
|
$('#COORDINATE_TYPE', window.parent.frames[0].document).val(0);// 赋值
|
|
|
|
});
|
|
}
|
|
})
|
|
|
|
|
|
|