PHP Modoer php页面和html调用地图

时间:2022-09-29 20:53:32

              最近在学习modoer点评系统,感觉很有意思。说一说调用地图的用法,首先来看看php页面怎么调用51地图。

首先在\static\javascript\map下有个51ditu.js和baidu.js

先写一段js代码,用iframe显示出地图

<script type="text/javascript">
$(document).ready(function(){
var point1 = point2 = '';
var width = 730;
var height = 450;
var title=$('#title').val();
point1 = $('#map_lng').val();
point2 = $('#map_lat').val();;
var url = Url('modoer/index/act/map/width/'+width+'/height/'+height+'/p1/'+point1+'/p2/'+point2);
if(point1 != '' && point2 != '') {
url += '&show=yes';
}
if($('#area_1').val()) {
url += '&city_id=' + $('#area_1').val();
}
if(title) {
url += '&title=' + title;
}
var html = '<iframe src="' + url + '" frameborder="0" scrolling="no" width="'+width+'" height="'+(height+10)+'" id="ifupmap_map"></iframe>';
$('#showmap').html(html);
});
</script>

html代码

  <ul class="tancount" style="display:none;">
<li>
<div>
<input type="hidden" id="title" value="<?php echo $sellerxxx_detail['name'] ?>" />
<input type="hidden" id="map_lng" value="<?php echo $sellerxxx_detail['map_lng'] ?>" />
<input type="hidden" id="map_lat" value="<?php echo $sellerxxx_detail['map_lat'] ?>" />
</div>
<div id="showmap"></div>
</li>
</ul>