# jquery-gaodemap **Repository Path**: dungang/jquery-gaodemap ## Basic Information - **Project Name**: jquery-gaodemap - **Description**: 高德地图jquery行政区域地址定位插件 - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-02-03 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # jquery-gaodemap 高德地图jquery行政区域地址定位插件 使用地图控件的前提是要到高德地图开发平台注册账户,申请key ```html ``` ![模态框](demo/demo-1.png) ## 根据经纬度定位 ```html
``` ## 行政区域选择 ```html
``` ## 行政区域选择+定位+弹出框 ![模态框](demo/demo-3.png) ![模态框](demo/demo-31.png) > html代码部分 ```html
``` > js代码部分 ```js $(document).ready(function () { var area = $('#map-box').gaodeArea().data('map.gaode.area'); $('#save-btn').click(function () { area.getValues(function (values) { //字段转换 var map = { province: 'provinceCode', provinceText: 'province', city: 'cityCode', cityText: 'city', district: 'districtCode', districtText: 'district', address: 'address', location: 'geo' }; //生成地理酒店地理位置信息的隐藏字段 var html = ''; for (var p in values) { var val = values[p]; if (map[p]) html += ''; } $('#hiddenArea').html(html); //组合完整地址 $('#full-addr').html( values['provinceText'] + values['cityText'] + values['districtText'] + values['address']); }); //查询酒店周边的信息,并生成隐藏字段 area.searchNearBy('地铁站|机场|景点|公交站', function (pois) { $('#hiddenNearby').html($.map(pois, function (item) { var lng = item.location.lng; var lat = item.location.lat; var geo = '{"lng":' + lng + ',"lat":' + lat + '}'; return ""; }).join('')); }); }); $('form').submit(function () { //如果直接提交表单,return true //如果ajax提交表单,在这里编写异步提交。return false return false; }); }); ``` MIT License Copyright (c) 2018 顿刚 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.