zoukankan      html  css  js  c++  java
  • 使用定位,逆地理编码,经纬度《=转=》地址信息、逆地理编码,地址《=转=》经纬度,贼方便!!!!

    经纬度转地址信息

    // 逆地理编码,经纬度=》地址信息
    var lnglat = [lng, lat] AMap.plugin('AMap.Geocoder', function () {
      var geocoder = new AMap.Geocoder({
        city: '010',
        //城市设为北京,默认:“全国”
        radius: 1000,
        //范围,默认:500
        extensions: 'all',
      });
      geocoder.getAddress(lnglat, function (status, result) {
        if (status === 'complete' && result.info === 'OK') {
          // geocoder_CallBack(result);
          // console.log(result, "result");
          self.city = result.regeocode.addressComponent.city;
          self.resultData = result.regeocodeaddressComponent.city;
          localStorage.localCity = result.regeocode.addressComponent.city;
          localStorage.timestamp = new Date().getTime();
          localStorage.position = JSON.stringify(position);
          //将即将纬度存到本地
        }
      });
    });
    

    地址信息转经纬度

    // 逆地理编码,地址-》经纬度
    var address = '山东省苍山县';
    //详细地址
    AMap.plugin('AMap.Geocoder', function () {
      var geocoder = new AMap.Geocoder({
        city: '010',
        //城市设为北京,默认:“全国”
        radius: 1000,
        //范围,默认:500
        extensions: 'all'
      });
      geocoder.getAddress(address, function (status, result) {
        if (status === 'complete' && result.info === 'OK') {
          // geocoder_CallBack(result);
          // console.log(result, "result");
          self.city = result.regeocode.addressComponent.city;
          self.resultData = result.regeocode.addressComponent.city;
          localStorage.localCity = result.regeocode.addressComponent.city;
          localStorage.timestamp = new Date().getTime();
          localStorage.position = JSON.stringify(position);
          //将即将纬度存到本地
        }
      })
    });
    
  • 相关阅读:
    gojs常用API-画布定义
    页面开发的标准
    iis7.5做反向代理配置方法实例图文教程
    Tomcat实现反向代理
    nodejs的package.json依赖dependencies中 ^ 和 ~ 的区别
    dependencies与devDependencies的区别
    常见的cmd命令
    解决SecureCRT中文显示乱码
    ASP防XSS代码
    Android页面之间进行数据回传
  • 原文地址:https://www.cnblogs.com/fanzhen/p/12801750.html
Copyright © 2011-2022 走看看