Adsense与jQueryUI映射

Adsense与jQueryUI映射,jquery,google-maps,adsense,Jquery,Google Maps,Adsense,您可以在下面看到我显示地图和标记的代码(来自Json): $('map_canvas').gmap().bind('init',function(){ $.getJSON('../js/locate.php',函数(数据){ $.each(data.markers,function(i,marker){ var mapvalue=new google.maps.LatLng(marker.lation,marker.longitude); $('map_canvas').gmap('addMar

您可以在下面看到我显示地图和标记的代码(来自Json):

$('map_canvas').gmap().bind('init',function(){
$.getJSON('../js/locate.php',函数(数据){
$.each(data.markers,function(i,marker){
var mapvalue=new google.maps.LatLng(marker.lation,marker.longitude);
$('map_canvas').gmap('addMarker',{
“标记”:[“”+标记.类别+“”],
“位置”:mapvalue,
“界限”:对,
“icon':'../images/'+marker.category+'.png',
“动画”:google.maps.animation.DROP
})。单击(函数(){
$('map_canvas').gmap('openInfoWindow',{'content':''+marker.category+'
'},这个); setTimeout(“opencust(\'”+marker.id+“\');”,100); }); }); }); });
如何在我的地图上添加新的adsense脚本:


谢谢你的帮助

经过一点研究,我只做了几处改动就成功了。您需要执行以下步骤

  • 首先,在谷歌地图JS中加入Adsense。注意添加了libraries=adsense&

    <script src="http://maps.google.com/maps/api/js?libraries=adsense&sensor=true"></script>
    
    
    
  • 修改你的JS如下。注意$('map_canvas').gmap('get','map')

    $('map_canvas').gmap().bind('init',function(){
    $.getJSON('../js/locate.php',函数(数据){
    $.each(data.markers,function(i,marker){
    var mapvalue=new google.maps.LatLng(marker.lation,marker.longitude);
    $('map#u canvas').gmap('addMarker'{
    “标记”:[“”+标记.类别+“”],
    “位置”:mapvalue,
    “界限”:对,
    “icon':'../images/'+marker.category+'.png',
    “动画”:google.maps.animation.DROP
    })。单击(函数(){
    $('map_canvas').gmap('openInfoWindow',{'content':''+marker.category+'
    '},这个); setTimeout(“opencust(\'”+marker.id+“\');”,100); }); }); }); var adUnitDiv=document.createElement('div'); var adUnitOptions={ 格式:google.maps.adsense.AdFormat.HALF_横幅, 位置:google.maps.ControlPosition.TOP, 背景颜色:“#c4d4f3”, 边框颜色:'#e5ecf9', 标题颜色:“#0000cc”, text颜色:'#000000', urlColor:“#009900”, map:$('map#u canvas').gmap('get','map'), 可见:对, publisherId:“您的发布者ID” }; adUnit=new google.maps.adsense.adUnit(adUnitDiv,adUnitOptions); });

  • 你想在这里做什么?我只是想在我的地图上添加一个adsense广告。使用google脚本很容易,但我找不到一种方法将其用于jquery ui映射库。
    <script src="http://maps.google.com/maps/api/js?libraries=adsense&sensor=true"></script>
    
    $('#map_canvas').gmap().bind('init', function() {
        $.getJSON( '../js/locate.php', function(data) {
            $.each( data.markers, function(i, marker) {
                var mapvalue=new google.maps.LatLng(marker.latitude, marker.longitude);
                    $('#map_canvas').gmap('addMarker', {
                    'tags': [''+marker.category+''],
                    'position': mapvalue,
                    'bounds': true,
                    'icon':'../images/'+marker.category+'.png',
                    'animation':google.maps.Animation.DROP
                }).click(function() {
                    $('#map_canvas').gmap('openInfoWindow', { 'content': ''+marker.category+'<BR><div id="cust_content"></div>' }, this);
                    setTimeout("opencust(\'" +marker.id+"\');",100);
                });
            });
        });
        var adUnitDiv = document.createElement('div');
        var adUnitOptions = {
            format: google.maps.adsense.AdFormat.HALF_BANNER,
            position: google.maps.ControlPosition.TOP,
            backgroundColor: '#c4d4f3',
            borderColor: '#e5ecf9',
            titleColor: '#0000cc',
            textColor: '#000000',
            urlColor: '#009900',
            map: $('#map_canvas').gmap('get','map'),
            visible: true,
            publisherId: 'YOUR_PUBLISHER_ID'
        };
        adUnit = new google.maps.adsense.AdUnit(adUnitDiv, adUnitOptions);
    });