最新赞助活动温馨提示:自愿赞助服务器费用,学生和没有工作的整站资源免费下载!
头像

thinkphp整合百度地图示例源码演示下载

来源:http://www.erdangjiade.com/php/2666.html 沐浴春风 2017-05-25 17:51浏览(4540)

这是一个完整的小系统,后台添加经度和维度,及公司地址,公司名字,前台显示出来后台添加的地方,最新最实用的thinkphp整合百度地图示例源码,需要的同学请拿走哦.

0、请不要问“在不在”之类的问题,有问题直接问!1、学生或暂时没有工作的童鞋,整站资源免费下载!2、¥9.9充值终身VIP会员,加我微信,826096331 拉你进VIP群学习!3、程序员加油,技术改变世界。 在线 充值

thinkphp整合百度地图示例源码演示下载
分类:PHP > 插件 难易:高级
查看演示 下载资源:

加我微信,拉你进VIP群学习:

下载资源 下载积分: 500 积分

thinkphp结合百度地图API整合,网上乱七八糟的有好多,但没有一个是完整版的,今天就试着写了一个前台加后台的小系统

<?php
/**
 * Created by PhpStorm.
 * User: www.erdangjiade.com
 * Date: 2017/5/24
 * Time: 15:07
 * QQ 826096331
 */

namespace Admin\Controller;
use Think\Controller;
class MapController extends Controller
{
    public function _initialize()
    {
        if(empty($_SESSION['user'])){
            $this->redirect('Index/index');
        }
    }
    //所有数据
    public function index(){

        $data=M('Map')->select();
        $this->assign('data',$data);
        $this->display();
    }
    //添加
    public function add(){
        if(IS_POST){
            if(empty(I('post.jd'))||empty(I('post.wd'))||empty(I('post.shop_name'))||empty(I('post.address'))){
                $this->error('请填写完整信息');
            }
            $data['jd']=trim(I('post.jd'));
            $data['wd']=trim(I('post.wd'));
            $data['shop_name']=trim(I('post.shop_name'));
            $data['address']=trim(I('post.address'));
            $data['tel']=trim(I('post.tel'));
            $data['url']="http://api.map.baidu.com/marker?location=$data[wd],$data[jd]&title=位置&content=$data[shop_name]&output=html";
            $res=M('Map')->add($data);
            if($res){
                $this->redirect('Map/index');
            }
        }else{
            $this->display();
        }
    }
    //删除
    public function del(){
        $id=I('get.id','');
        $res=M('Map')->where("id=$id")->delete();
        if($res){
            $this->success('删除成功');
        }else{
            $this->error('删除失败');
        }
    }

    public function edit(){
        if(IS_POST){
            $id=trim(I('post.id'));
            $data['jd']=trim(I('post.jd'));
            $data['wd']=trim(I('post.wd'));
            $data['shop_name']=trim(I('post.shop_name'));
            $data['address']=trim(I('post.address'));
            $data['tel']=trim(I('post.tel'));
            $data['url']="http://api.map.baidu.com/marker?location=$data[wd],$data[jd]&title=位置&content=$data[shop_name]&output=html";
            $res=M('Map')->where("id=$id")->save($data);
            if($res){
                $this->success('成功','index');
            }
        }else{
            $id=I('get.id','');
            $info=M('Map')->where("id=$id")->find();
            $this->assign('info',$info);
            $this->display();
        }
    }
}

前端页面代码

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<center>
    <table border="1">
        <tr>
            <td>公司号</td>
            <td>公司名</td>
            <td>公司地址</td>
            <td>联系方式</td>
            <td>地图</td>
            <td><a href="{:U('Index/all')}">查看所有</a></td>
        </tr>
        <foreach name="data" item="val">
            <tr>
                <td>{$val['id']}</td>
                <td>{$val['shop_name']}</td>
                <td>{$val['address']}</td>
                <td>{$val['tel']}</td>
                <td><a href="{$val['url']}">点击查看</a></td>
            </tr>
        </foreach>
    </table>
</center>
</body>
</html>
声明:本文为原创文章,如需转载,请注明来源erdangjiade.com并保留原文链接:https://www.erdangjiade.com/php/2666.html
评论29
头像

友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群

  • 头像 28楼
    11-29 11:54
    leiyong711
    刚好需要 这个好
  • 头像 27楼
    05-15 12:13
    水水水水水
    水水水水水水水水水水水水水水水水水水水
  • 头像 26楼
    03-15 14:20
    花一样的少年
    为什么不直接显示,要跳转有点不方便了!
  • 头像 25楼
    03-10 09:05
    654321
    这个是tp多少版本的呢?
  • 头像 24楼
    02-07 19:57
    250348734
    这个很牛逼啊!有意思啊!
  • 头像 23楼
    01-31 17:41
    lby_123
    666,玩的很是牛逼啊
  • 头像 22楼
    01-03 15:17
    阿涛来此学习
    0200161013 0200161013 0200161013
  • 头像 21楼
    12-05 11:05
    怪有意思a
    6666,怎么弄积分啊
  • 头像 20楼
    11-27 06:39
    一只小肥牛
    攒点积分
  • 头像 19楼
    11-07 14:13
    xuzhoushun
    http://www.erdangjiade.com/jquery/26/2666/demo/admin这是后台演示地址 是不是无法用了
1 2