基本信息
源码名称:百度地图搜索api-智能地方小吃搜索PHP源码
源码大小:8.50KB
文件格式:.php
开发语言:PHP
更新时间:2019-04-06
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

度娘搜搜百度地图搜索api-智能地方小吃搜索PHP源码
1、功能介绍:
   度娘搜搜网根据研究百度地图搜索API的一些心得,实现度娘地方小吃地图搜索php代码,因此以百度地图搜索API范例的方式发布,链接地址:http://www.dnsoso.com/map-api/,并且不断更新中,度娘地方小吃地图搜索的功能主要集中在动态的用户IP地址定位,也就是访客定位,还有就是利用baidu地图API的搜索功能,智能搜索访客喜欢的地方小吃,如烧烤、麻辣烫、烤鱼等等,搜索工具采用的是易于网站发布的PHP源代码,代码的简单文字调整,马上就可以形成用户希望的搜索工具,因此,该工具不仅仅是针对的地方小吃的搜索,你也可以搜历史古迹或旅游景点等等。
本站发布该搜索功能的目的主要是用于百度地图API开发者间的交流与经验分享,待合适的时机,小度将提供完整的百度地图搜索API开发范例源代码,供大家参考和使用。
功能技术特点:
(1)访客ip地址城市定位;
(2)php环境下实现百度地图api相关的json接口数据提取;
(3)用户访问自动搜索关键信息
(4)SEO支持,用户访问后动态生成动态页面,包含动态title、描述等
2、使用说明:
   index.php直接上传目标目录可直接使用,建议最好上百度地图官方免费新申请百度地图api开发者应用,不申请也能用。

<?php
$url1=$_GET["chengshi"];
$select1=$_GET["select"];
if (empty($select1)){  

 $select1="小吃";
  $select2="烧烤";
 }
// 源代码有度娘搜搜原创出品,如有技术问题或参考相关效果,请访问度娘搜搜 http://www.dnsoso.com
// 定义一个函数getIP() 
function getIP() 
{ 
global $ip; 

if (getenv("HTTP_CLIENT_IP")) 
$ip = getenv("HTTP_CLIENT_IP"); 
else if(getenv("HTTP_X_FORWARDED_FOR")) 
$ip = getenv("HTTP_X_FORWARDED_FOR"); 
else if(getenv("REMOTE_ADDR")) 
$ip = getenv("REMOTE_ADDR"); 
else 
$ip = "Unknow"; 

return $ip; 
} 

// 使用方法: 
//echo getIP(); 

?>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="initial-scale=1.0, user-scalable=yes" />
	<style type="text/css">
		body, html,#allmap {width: 100%;height: 100%; margin:0;font-family:"微软雅黑";vertical-align:middle;}
		#l-map{height:300px;width:100%;}
		#r-result{width:100%;}
    a:link {
	color: #000000;
	text-decoration: none;
}
a:visited {
	color: #000000;
	text-decoration: none;
}
a:hover {
	text-decoration: underline;
	color: #FF3300;
}
a:active {
	text-decoration: none;
}
a {
	font-size: 12px;
	color: #000000;
}
body,td,th {
	font-size: 12px;
	color: #000000;
}
.STYLE2 {color: #FFFFFF}
    .STYLE3 {color: #000000}
    </style>
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=C70827b03b921d8d0579e76726654eea"></script>  
<!-- 
以上是度娘搜搜为百度地图开发api申请的应用KEY授权,大家也可使用,但建议大家自己去百度地图官网免费申请。
 -->
	<?php
if (empty($url1)){  
echo '<title>地方小吃搜索|百度地图搜索API开发范例|度娘搜搜</title>';
echo '<meta name="description" content="度娘搜搜网为帮助百度地图API开发者和爱好者提升开发水平,特编写开发地方小吃地图搜索平台,可实现基于百度地图API的地图智能搜索功能,具体可实现访客用户的IP地址定位功能,并自动搜索全国各地自助烧烤店、烤吧、烤鱼、烤串、海鲜排挡、麻辣龙虾等特色地方小吃,可提供网站全套PHP源代码,搜索词简单配置修改即可用于各类行业,方便各类网站引用。" />';
echo '<meta name="keywords" content="地方小吃搜索,百度地图搜索API,度娘搜索,度娘地图" />';
 }
 else
 { 
 echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>度娘搜搜 - 地方小吃搜索';
 echo "|".$url1.$select1."特色小吃</title>";    }
 ?>
	
</head>
<body>
<p align="center">
<a href="http://www.dnsoso.com/"><img src="http://www.dnsoso.com/image/logomain.png" alt="度娘搜搜网站logo" align="bottom" border="0"></a><br>
	<?php
$content = file_get_contents("http://api.map.baidu.com/location/ip?ak=C70827b03b921d8d0579e76726654eea&ip=".getIP()."&coor=bd09ll");
$content = json_decode($content);
// json接口数据提取
 ?>

</p>

<div align="center"><a href="http://www.dnsoso.com" target="_self">【度娘搜搜首页】</a> &nbsp;<a href="http://www.dnsoso.com/category/zhidao/" target="_self">【度娘知道】</a>&nbsp;<a href="http://www.dnsoso.com/category/seo/" target="_self">【百度SEO】</a>&nbsp;<a href="http://www.dnsoso.com/category/news/" target="_self">【度娘新闻】</a>&nbsp;<a href="http://www.dnsoso.com/tag/baidumap/" target="_self">【技术问答】</a>

</div>

<form action="http://www.dnsoso.com/map-api/" name="guji" target="_self" id="guji">
  <div align="center">
    <p align="center"><span class="STYLE7">城市/县名称:</span>
      <input  name="chengshi" type="text"  size=18  style="color='ccc';width:100px" onClick="this.style.color='black';" onBlur="this.style.color=''">
    &nbsp;&nbsp;
      <label >小吃类型:
      <select name="select" size="" style="width:100px" >
        <option selected>小吃</option>
        <option>烧烤</option>
        <option>烤鱼</option>
        <option>麻辣龙虾</option>
        <option>海鲜排挡</option>
        <option>烤全羊</option>
        <option>麻辣烫</option>
      </select>
</label>
    </p>
    <p>
      <input type="submit" value="地方小吃查询">
      
    </p>
  </div>
  

    <div align="center">
	<?php
echo '<span class="STYLE1">您当前所在城市:</span><a href="/map-api/?chengshi='.$content->content->address_detail->city.'" target="_self">'.$content->content->address_detail->city.'</a>  <span class="STYLE1">正在搜索:</span><a href="/map-api/?chengshi='.$url1.'&select='.$select1.'" target="_self">'.$url1.$select1.'</a>';
if (empty($url1)){  
$url1=$content->content->address_detail->city;

 }
?>
  </div>
  
  

<table width="468" align="center" style="border: 0px solid &#35;000000; ">
<tr>
<td>
<div align="center" class="bdsharebuttonbox">
    <div align="center"><a class="bds_more" href="#" data-cmd="more">度娘微分享:</a><a class="bds_weixin" title="分享到微信" href="#" data-cmd="weixin">微信</a><a class="bds_tsina" title="分享到新浪微博" href="#" data-cmd="tsina">新浪微博</a><a class="bds_tqq" title="分享到腾讯微博" href="#" data-cmd="tqq">腾讯微博</a><a href="http://www.dnsoso.com/tougao/">软文投稿</a></div>
  </div>
    <div align="center">
          <script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{"bdSize":16},"image":{"viewList":["weixin","tsina","tqq"],"viewText":"分享到:","viewSize":"16"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["weixin","tsina","tqq"]}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' ~(-new Date()/36e5)];</script>        
      </div>
</td> 
</tr>
 <!--  
<table width="468" align="center" style="border: 1px solid &#35;000000; ">
<tr>
<td>

 <?php include 'outsite-insert.php';?>


</td> 
</tr> 
</table> <br> -->
<table width="468" align="center" style="border: 1px solid &#35;000000; ">
<tr>
<td>
	<div id="l-map"></div>
	<div id="r-result"></div>
</td> 
</tr> 
</table> 
<table width="468" align="center" style="border: 0px solid &#35;000000; ">
<tr>
<td>
<!-- 多说评论框 start -->
	<div class="ds-thread" data-thread-key="<?php echo $url1; ?>" data-title="" data-url=""></div>
<!-- 多说评论框 end -->
<!-- 多说公共JS代码 start (一个网页只需插入一次) -->
<script type="text/javascript">
var duoshuoQuery = {short_name:"dnsoso"};
	(function() {
		var ds = document.createElement('script');
		ds.type = 'text/javascript';ds.async = true;
		ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:')   '//static.duoshuo.com/embed.js';
		ds.charset = 'UTF-8';
		(document.getElementsByTagName('head')[0] 
		 || document.getElementsByTagName('body')[0]).appendChild(ds);
	})();
	</script>
<!-- 多说公共JS代码 end -->
</td> 
</tr> 
</table> 

<p align="center">
Copyright© 2015 度娘搜搜&nbsp;&nbsp;保留所有权利.&nbsp; &nbsp;鲁ICP备15005183号-1
 &nbsp; &nbsp;
&nbsp; &nbsp;
<!-- 统计代码 请自行替换 -->
<script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1254491856'%3E%3C/span%3E%3Cscript src='"   cnzz_protocol   "s4.cnzz.com/z_stat.php%3Fid%3D1254491856' type='text/javascript'%3E%3C/script%3E"));</script>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?edc9e3af192a3bf7db45807e8492792b";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

<script language="javascript" type="text/javascript" src="http://js.users.51.la/18199890.js"></script>
<noscript><a href="http://www.51.la/?18199890" target="_blank"><img alt="我要啦免费统计" src="http://img.users.51.la/18199890.asp" style="border:none" /></a></noscript>

</p>


	
</body>
</html>
<script type="text/javascript">
	// 百度地图API功能
	var map = new BMap.Map("l-map");            // 创建Map实例
	map.centerAndZoom("<?php echo $url1; ?>", 11);
	var myKeys = ["烤之源","<?php echo $select1; ?>"];
	var local = new BMap.LocalSearch("<?php echo $url1; ?>", {
		renderOptions:{map: map, panel:"r-result"},
		pageCapacity:6
	});
	local.searchInBounds(myKeys, map.getBounds());
</script>