一、注册Api账号,引用js库
二、编写坐标拾取js代码和html代码
//按钮定义
*坐标:
经度
纬度
点击坐标拾取
//弹出框定义
×
拖动位置标记设置坐标
确定
js代码示例
//选择坐标处理
var map;
var marker;
var init = function () {
var center = new qq.maps.LatLng(39.916527, 116.397128);
map = new qq.maps.Map(document.getElementById('mapContainer'), {
center: center,
zoom: 13
});
//获取城市列表接口设置中心点
citylocation = new qq.maps.CityService({
complete: function (result) {
map.setCenter(result.detail.latLng);
//添加标记
marker= new qq.maps.Marker({
position: result.detail.latLng,
draggable: true,
map: map
});
//添加到提示窗
var info = new qq.maps.InfoWindow({
map: map
});
qq.maps.event.addListener(marker, 'mouseup', function (e) {
//获取经纬度 e.latLng
//获取坐标 e.cursorPixel
info.open();
info.setContent('
坐标:' + e.latLng.lat + ',' + e.latLng.lng + '');
info.setPosition(e.latLng);
$scope.entity.Longitude = e.latLng.lng;
$scope.entity.Latitude = e.latLng.lat;
$scope.$apply();
});
}
});
//调用searchLocalCity();方法 根据用户IP查询城市信息。
citylocation.searchLocalCity();
}
init();
$scope.mapShow = function () {
$('#mapModal').modal('show');
if ($scope.entity.Latitude != undefined) {
var point = new qq.maps.LatLng($scope.entity.Latitude, $scope.entity.Longitude);
map.setCenter(point);
marker.setPosition(point);
}
}
三、添加或修改时坐标对应截图
更多:
常用电子面单接口对接技术文档_菜鸟_快递鸟
爬取Ip地址对应的物理位置等信息-百度服务器
新浪微博登陆,获取微博用的信息