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);
          //将即将纬度存到本地
        }
      })
    });
    
  • 相关阅读:
    Linux主要shell命令详解(下)
    mget命令, ftp命令详解
    VI 基本可视模式
    vim使用技巧
    cd及目录快速切换
    du命令解决linux磁盘空间满的问题(很不错的哦)
    Mysql删除数据后磁盘空间未释放的解决办法【转】
    MYSQL-innodb性能优化几个点
    Apache服务器出现Forbidden 403错误提示的解决方法总结
    MySQL 分区表原理及数据备份转移实战
  • 原文地址:https://www.cnblogs.com/fanzhen/p/12801750.html
Copyright © 2011-2022 走看看