body, html,#allmap {width: 100%;height: 80%;overflow: hidden;margin:0;font-family:"微软雅黑";}
// 百度地图API功能
$(function(){
location1();
});
function navigation(){
var longitude = 119.317827;//经度
var latitude = 26.090568;//纬度
var storeName = '我的的小店';
var storeAddr = '世外桃源';
var str="http://api.map.baidu.com/marker?location="+latitude+","+longitude+"&title="+storeName+"&content="+storeAddr+"&output=html&src=yourCompanyName";
$("#mytest").attr("href",str);
initMapConverseReAddressMobile("allmap",11,"pointllentity");
theLocationBylnglat(15,longitude,latitude,"pointllentity");
};
function location1(){
var map = new BMap.Map("allmap");
var point = new BMap.Point();
map.centerAndZoom(point,28);
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r){
console.log(this)
if(this.getStatus() == 0){
var mk = new BMap.Marker(r.point);
map.addOverlay(mk);
map.panTo(r.point);
alert('您的位置:'+r.point.lng+','+r.point.lat);
point=r.point;
test(point);
}
else {
alert('failed'+this.getStatus());
}
},{enableHighAccuracy: true});
};
function test(point){
var geoc = new BMap.Geocoder();
geoc.getLocation(point, function(rs){
console.log(rs);
console.log("------");
console.log(point);
var addComp = rs.addressComponents;
alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
});
};