├── reademe.txt ├── screenshot.png ├── .gitignore ├── README.md ├── LICENSE └── wp-amaps.php /reademe.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rccoder/wp-amaps/HEAD/reademe.txt -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rccoder/wp-amaps/HEAD/screenshot.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .htaccess 3 | sitemap.xml 4 | sitemap.xml.gz 5 | wp-config.php 6 | wp-content/advanced-cache.php 7 | wp-content/backup-db/ 8 | wp-content/backups/ 9 | wp-content/blogs.dir/ 10 | wp-content/cache/ 11 | wp-content/upgrade/ 12 | wp-content/uploads/ 13 | wp-content/wp-cache-config.php 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wp-amaps 2 | A WordPress Plugin Powered By [Amaps](http://ditu.amap.com/) 3 | 4 | ![show](./screenshot.png) 5 | 6 | ## Usage 7 | 8 | ``` 9 | [amaps id='myid' w='100px' h='100px' lon='126.633286' lat='45.747425' address='哈尔滨工业大学一校区' info='这是一个很好的大学'] 10 | ``` 11 | Or 12 | ``` 13 | [amaps lon='126.633286' lat='45.747425' address='哈尔滨工业大学一校区' info='这是一个很好的大学'] 14 | ``` 15 | Or 16 | ``` 17 | [amaps address='哈尔滨工业大学一校区' info='这是一个很好的大学'] 18 | ``` 19 | Or 20 | ``` 21 | [amaps lon='126.633286' lat='45.747425' info='这是一个很好的大学'] 22 | ``` 23 | Or 24 | ``` 25 | [amaps address='哈尔滨工业大学一校区'] 26 | ``` 27 | 28 | with `id`, you can customize style for map 29 | 30 | with `w` and `h`, you can customize weight and height for map 31 | 32 | ## Issues 33 | If you have any question, you can click [Issues](https://github.com/rccoder/wp-amaps/issues) and open a new Issues. 34 | 35 | ## Download 36 | [wp-amaps](https://wordpress.org/plugins/wp-amaps/) 37 | 38 | ## Version 39 | * 1.0 40 | * 1.2 41 | * 1.3 42 | * 1.4 43 | * 1.5 44 | * 1.6 45 | * 1.7 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Shangbin Yang 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /wp-amaps.php: -------------------------------------------------------------------------------- 1 | '', 36 | 'w'=>'', 37 | 'h'=>'', 38 | 'lon'=>'', 39 | 'lat'=>'', 40 | 'address'=>'', 41 | 'info' => '', 42 | ) ,$atts)); 43 | 44 | $id = $id ? $id : 'wp_amaps'; 45 | $w = $w ? $w : '100%'; 46 | $h = $h ? $h : '300px'; 47 | $lon = $lon ? $lon : false; 48 | $lat = $lat ? $lat : false; 49 | $address = $address ? $address : false; 50 | $info = $info ? $info : false; 51 | 52 | $str1 = '
'; 53 | $str2 = ''; 57 | 58 | if (($lon && $lat) || $address) { 59 | $output = $str1; 60 | $output .= $str2; 61 | 62 | if($lon && $lat) { 63 | $output .= $lon.','.$lat; 64 | if (! $address) { 65 | $tep = file_get_contents("http://restapi.amap.com/v3/geocode/regeo?output=json&location=".$lon.",".$lat."&key=71587fdfc4998f07b4ddd25846f193b7&radius=1000"); 66 | $tep = json_decode($tep); 67 | $address = $tep->regeocode->formatted_address; 68 | } 69 | } else if ($address){ 70 | $tep = file_get_contents("http://restapi.amap.com/v3/geocode/geo?address=".$address."&output=json&key=71587fdfc4998f07b4ddd25846f193b7"); 71 | $tep = json_decode($tep); 72 | $tep = $tep->geocodes[0]->location; 73 | $output .= $tep; 74 | } 75 | 76 | $output .= $str3; 77 | $output .= $address; 78 | $output .= $str4; 79 | 80 | if ($info) { 81 | $output .= $info; 82 | } else { 83 | $output .= $address; 84 | } 85 | 86 | $output .= $str5; 87 | return $output; 88 | } 89 | } 90 | ?> --------------------------------------------------------------------------------