2014-10-20 87 views
-1

我想改进我的Google Map并在那里添加Marker Cluster功能,但我真的不知道如何继续。它仍然给我灰色地图(没有显示)。谷歌地图 - Marker Cluster问题

有没有人可以检查代码并给我提示?

谢谢。

这是代码,我使用(抱歉大阵):

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
<script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer.js"></script> 
<script type="text/javascript"> 
var infowindow = null; 
    $(document).ready(function() { initialize(); }); 

    function initialize() { 

    var centerMap = new google.maps.LatLng(95.32, 14.82); 

    var myOptions = { 
     zoom: 0, 
     center: centerMap, 
     mapTypeId: google.maps.MapTypeId.HYBRID } 

    var map = new google.maps.Map(document.getElementById("map_radius_canvas"), myOptions); 

    var markerCluster = new MarkerClusterer(map, sites); 

    setMarkers(map, sites); 
    infowindow = new google.maps.InfoWindow({ 
     content: "loading..." 
    }); 

    var LatLngList = new Array (
     new google.maps.LatLng(11.0168445, 76.9558321), new google.maps.LatLng(11.0168445, 76.9558321), new google.maps.LatLng(11.0168445, 76.9558321), new google.maps.LatLng(11.0168445, 76.9558321), new google.maps.LatLng(-3.7318616, -38.5266704), new google.maps.LatLng(21.3967, -157.8994), new google.maps.LatLng(45.4278901, -75.6958523), new google.maps.LatLng(26.8465108, 80.9466832), new google.maps.LatLng(30.9602, -85.1639), new google.maps.LatLng(33.9737, -87.0043) ); 

      var bounds = new google.maps.LatLngBounds(); 
     for (var i = 0, LtLgLen = LatLngList.length; i < LtLgLen; i++) { 
     bounds.extend (LatLngList[i]); 
     } 

     map.fitBounds (bounds); 

     var bikeLayer = new google.maps.BicyclingLayer(); 
     bikeLayer.setMap(map); 
     } 

     var sites = [ 
        ['Hyper Active/Dyslexia/No Speech/Speech Therapy in Residential School', 11.0168445, 76.9558321, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/classes/tutoring-private-lessons/hyper-active-dyslexia-no-speech-speech-therapy-in-residential-school_i171"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/uploads/1/46_thumbnail.jpg"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/classes/tutoring-private-lessons/hyper-active-dyslexia-no-speech-speech-therapy-in-residential-school_i171">Hyper Active/Dyslexia/No Speech/Speech Therapy in Residential School</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/classes/tutoring-private-lessons/hyper-active-dyslexia-no-speech-speech-therapy-in-residential-school_i171">Nothing to Worry. Divine, Holistic Meditation Yoga and occupational speech, Akarshane therapies and lots more would give your wards the best life and ...</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'] 
      ,    ['RESIDENTIAL SCHOOL ADMISSIONS/SECURING THE HIGHEST RESULTS IN XII EXAMS', 11.0168445, 76.9558321, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/classes/tutoring-private-lessons/residential-school-admissions-securing-the-highest-results-in-xii-exams_i170"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/uploads/1/45_thumbnail.jpg"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/classes/tutoring-private-lessons/residential-school-admissions-securing-the-highest-results-in-xii-exams_i170">RESIDENTIAL SCHOOL ADMISSIONS/SECURING THE HIGHEST RESULTS IN XII EXAMS</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/classes/tutoring-private-lessons/residential-school-admissions-securing-the-highest-results-in-xii-exams_i170">Behaviour Issues in YOUR CHILDREN - In IX, X standards as well XII - The Children are not listening to the Parents, screaming, shouting etc, while you...</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'] 
      ,    ['LOW BUDGET HOSTEL STUDIES AVAILABLE FOR MATRICULATION BOARD CHILDREN', 11.0168445, 76.9558321, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/classes/tutoring-private-lessons/low-budget-hostel-studies-available-for-matriculation-board-children_i169"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/uploads/1/44_thumbnail.jpg"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/classes/tutoring-private-lessons/low-budget-hostel-studies-available-for-matriculation-board-children_i169">LOW BUDGET HOSTEL STUDIES AVAILABLE FOR MATRICULATION BOARD CHILDREN</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/classes/tutoring-private-lessons/low-budget-hostel-studies-available-for-matriculation-board-children_i169">Are your children studying good and because of your Financial issues? Are you getting shuffled between your job, your house and Responsibilities? If ...</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'] 
      ,    ['Want Admissions in Higher Secondary for Biology Group/First Group in XI', 11.0168445, 76.9558321, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/classes/tutoring-private-lessons/want-admissions-in-higher-secondary-for-biology-group-first-group-in-xi_i168"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/uploads/1/43_thumbnail.jpg"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/classes/tutoring-private-lessons/want-admissions-in-higher-secondary-for-biology-group-first-group-in-xi_i168">Want Admissions in Higher Secondary for Biology Group/First Group in XI</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/classes/tutoring-private-lessons/want-admissions-in-higher-secondary-for-biology-group-first-group-in-xi_i168">Do you want admission in +1 &amp; Maths/Biology/Computer Science admissions for your ward? Do you fear your children would score minimum marks in...</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'] 
      ,    ['hello tetest', -3.7318616, -38.5266704, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/for-sale/art-collectibles/hello-tetest_i167"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/themes/sofia/images/no_photo.gif"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/for-sale/art-collectibles/hello-tetest_i167">hello tetest</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/for-sale/art-collectibles/hello-tetest_i167">test htis is</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'] 
      ,    ['Hayabusa', 21.3967, -157.8994, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/vehicles/motorcycles/hayabusa_i158"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/uploads/1/36_thumbnail.jpg"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/vehicles/motorcycles/hayabusa_i158">Hayabusa</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/vehicles/motorcycles/hayabusa_i158">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500...</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'] 
      ,    ['teste', 45.4278901, -75.6958523, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/for-sale/animals/teste_i166"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/uploads/1/39_thumbnail.jpg"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/for-sale/animals/teste_i166">teste</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/for-sale/animals/teste_i166">teste</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'] 
      ,    ['Car Is your but EMI is Ours | Yop Services', 26.8465108, 80.9466832, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/vehicles/cars/car-is-your-but-emi-is-ours-yop-services_i165"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/themes/sofia/images/no_photo.gif"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/vehicles/cars/car-is-your-but-emi-is-ours-yop-services_i165">Car Is your but EMI is Ours | Yop Services</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/vehicles/cars/car-is-your-but-emi-is-ours-yop-services_i165">New concept of advertisement is coming in the market through strategy of branding on wheels. TAKE A NEW BRAND CAR ONLY ON LESS THAN HALF AMOUNT OF THE...</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'] 
      ,    ['Top House in Malibu', 30.9602, -85.1639, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/for-sale/barter/top-house-in-malibu_i28"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/themes/sofia/images/no_photo.gif"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/for-sale/barter/top-house-in-malibu_i28">Top House in Malibu</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/for-sale/barter/top-house-in-malibu_i28">Not included as villae were the domus, a city house for the élite and privileged classes; and insulae, blocks of apartment buildings for the rest of t...</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'] 
      ,    ['15 rooms Villa in Bremen', 33.9737, -87.0043, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/for-sale/animals/15-rooms-villa-in-bremen_i27"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/themes/sofia/images/no_photo.gif"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/for-sale/animals/15-rooms-villa-in-bremen_i27">15 rooms Villa in Bremen</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/for-sale/animals/15-rooms-villa-in-bremen_i27">In ancient Roman architecture a villa was originally a country house built for the élite. Pliny the Elder, writing in the first century CE, identified...</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'] 
       ]; 


    function setMarkers(map, markers) { 
     for (var i = 0; i < markers.length; i++) { 
     var sites = markers[i]; 
     var siteLatLng = new google.maps.LatLng(sites[1], sites[2]); 
     var marker = new google.maps.Marker({ 
      position: siteLatLng, 
      map: map, 
      title: sites[0], 
      html: sites[3], 
      icon: sites[4] 
     }); 

     var contentString = "Related items"; 

     google.maps.event.addListener(marker, "click", function() { 
      infowindow.setContent(this.html); 
      infowindow.open(map, this); 
     }); 
     } 
    } 
</script> 

回答

0

网站是不是google.maps.Markers

类似问题的数组:

解决该问题的一种方法是在setMarkers函数中创建一个google.maps.Marker对象数组并返回它。工作代码片段:

var infowindow = null; 
 
$(document).ready(function() { 
 
    initialize(); 
 
}); 
 

 
function initialize() { 
 

 
    var centerMap = new google.maps.LatLng(95.32, 14.82); 
 

 
    var myOptions = { 
 
    zoom: 0, 
 
    center: centerMap, 
 
    mapTypeId: google.maps.MapTypeId.HYBRID 
 
    }; 
 

 
    var map = new google.maps.Map(document.getElementById("map_radius_canvas"), myOptions); 
 

 

 

 
    var gmarkers = setMarkers(map, sites); 
 
    var markerCluster = new MarkerClusterer(map, gmarkers); 
 
    infowindow = new google.maps.InfoWindow({ 
 
    content: "loading..." 
 
    }); 
 

 
    var LatLngList = new Array(
 
    new google.maps.LatLng(11.0168445, 76.9558321), new google.maps.LatLng(11.0168445, 76.9558321), new google.maps.LatLng(11.0168445, 76.9558321), new google.maps.LatLng(11.0168445, 76.9558321), new google.maps.LatLng(-3.7318616, -38.5266704), new google.maps.LatLng(21.3967, -157.8994), new google.maps.LatLng(45.4278901, -75.6958523), new google.maps.LatLng(26.8465108, 80.9466832), new google.maps.LatLng(30.9602, -85.1639), new google.maps.LatLng(33.9737, -87.0043)); 
 

 
    var bounds = new google.maps.LatLngBounds(); 
 
    for (var i = 0, LtLgLen = LatLngList.length; i < LtLgLen; i++) { 
 
    bounds.extend(LatLngList[i]); 
 
    } 
 

 
    map.fitBounds(bounds); 
 

 
    var bikeLayer = new google.maps.BicyclingLayer(); 
 
    bikeLayer.setMap(map); 
 
} 
 

 
var sites = [ 
 
    ['Hyper Active/Dyslexia/No Speech/Speech Therapy in Residential School', 11.0168445, 76.9558321, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/classes/tutoring-private-lessons/hyper-active-dyslexia-no-speech-speech-therapy-in-residential-school_i171"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/uploads/1/46_thumbnail.jpg"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/classes/tutoring-private-lessons/hyper-active-dyslexia-no-speech-speech-therapy-in-residential-school_i171">Hyper Active/Dyslexia/No Speech/Speech Therapy in Residential School</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/classes/tutoring-private-lessons/hyper-active-dyslexia-no-speech-speech-therapy-in-residential-school_i171">Nothing to Worry. Divine, Holistic Meditation Yoga and occupational speech, Akarshane therapies and lots more would give your wards the best life and ...</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'], 
 
    ['RESIDENTIAL SCHOOL ADMISSIONS/SECURING THE HIGHEST RESULTS IN XII EXAMS', 11.0168445, 76.9558321, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/classes/tutoring-private-lessons/residential-school-admissions-securing-the-highest-results-in-xii-exams_i170"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/uploads/1/45_thumbnail.jpg"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/classes/tutoring-private-lessons/residential-school-admissions-securing-the-highest-results-in-xii-exams_i170">RESIDENTIAL SCHOOL ADMISSIONS/SECURING THE HIGHEST RESULTS IN XII EXAMS</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/classes/tutoring-private-lessons/residential-school-admissions-securing-the-highest-results-in-xii-exams_i170">Behaviour Issues in YOUR CHILDREN - In IX, X standards as well XII - The Children are not listening to the Parents, screaming, shouting etc, while you...</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'], 
 
    ['LOW BUDGET HOSTEL STUDIES AVAILABLE FOR MATRICULATION BOARD CHILDREN', 11.0168445, 76.9558321, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/classes/tutoring-private-lessons/low-budget-hostel-studies-available-for-matriculation-board-children_i169"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/uploads/1/44_thumbnail.jpg"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/classes/tutoring-private-lessons/low-budget-hostel-studies-available-for-matriculation-board-children_i169">LOW BUDGET HOSTEL STUDIES AVAILABLE FOR MATRICULATION BOARD CHILDREN</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/classes/tutoring-private-lessons/low-budget-hostel-studies-available-for-matriculation-board-children_i169">Are your children studying good and because of your Financial issues? Are you getting shuffled between your job, your house and Responsibilities? If ...</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'], 
 
    ['Want Admissions in Higher Secondary for Biology Group/First Group in XI', 11.0168445, 76.9558321, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/classes/tutoring-private-lessons/want-admissions-in-higher-secondary-for-biology-group-first-group-in-xi_i168"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/uploads/1/43_thumbnail.jpg"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/classes/tutoring-private-lessons/want-admissions-in-higher-secondary-for-biology-group-first-group-in-xi_i168">Want Admissions in Higher Secondary for Biology Group/First Group in XI</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/classes/tutoring-private-lessons/want-admissions-in-higher-secondary-for-biology-group-first-group-in-xi_i168">Do you want admission in +1 &amp; Maths/Biology/Computer Science admissions for your ward? Do you fear your children would score minimum marks in...</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'], 
 
    ['hello tetest', -3.7318616, -38.5266704, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/for-sale/art-collectibles/hello-tetest_i167"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/themes/sofia/images/no_photo.gif"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/for-sale/art-collectibles/hello-tetest_i167">hello tetest</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/for-sale/art-collectibles/hello-tetest_i167">test htis is</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'], 
 
    ['Hayabusa', 21.3967, -157.8994, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/vehicles/motorcycles/hayabusa_i158"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/uploads/1/36_thumbnail.jpg"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/vehicles/motorcycles/hayabusa_i158">Hayabusa</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/vehicles/motorcycles/hayabusa_i158">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500...</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'], 
 
    ['teste', 45.4278901, -75.6958523, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/for-sale/animals/teste_i166"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/uploads/1/39_thumbnail.jpg"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/for-sale/animals/teste_i166">teste</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/for-sale/animals/teste_i166">teste</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'], 
 
    ['Car Is your but EMI is Ours | Yop Services', 26.8465108, 80.9466832, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/vehicles/cars/car-is-your-but-emi-is-ours-yop-services_i165"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/themes/sofia/images/no_photo.gif"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/vehicles/cars/car-is-your-but-emi-is-ours-yop-services_i165">Car Is your but EMI is Ours | Yop Services</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/vehicles/cars/car-is-your-but-emi-is-ours-yop-services_i165">New concept of advertisement is coming in the market through strategy of branding on wheels. TAKE A NEW BRAND CAR ONLY ON LESS THAN HALF AMOUNT OF THE...</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'], 
 
    ['Top House in Malibu', 30.9602, -85.1639, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/for-sale/barter/top-house-in-malibu_i28"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/themes/sofia/images/no_photo.gif"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/for-sale/barter/top-house-in-malibu_i28">Top House in Malibu</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/for-sale/barter/top-house-in-malibu_i28">Not included as villae were the domus, a city house for the élite and privileged classes; and insulae, blocks of apartment buildings for the rest of t...</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'], 
 
    ['15 rooms Villa in Bremen', 33.9737, -87.0043, '<div style="width:300px;max-width:300px;display:block;height:70px;max-height:70px;overflow: hidden;"><a style="width:28%;float:left;clear:both;" href="http://your_site.com/for-sale/animals/15-rooms-villa-in-bremen_i27"><img style="width:100%;height:auto;border:1px solid #ddd;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;" src="http://your_site.com/oc-content/themes/sofia/images/no_photo.gif"/></a><a style="margin-left:2%;font-weight:bold;width:70%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;float:left;color:#333;text-decoration:underline;font-size:13px;margin-bottom:4px;" href="http://your_site.com/for-sale/animals/15-rooms-villa-in-bremen_i27">15 rooms Villa in Bremen</a><a style="margin-left:2%;width:70%;float:left;color:#777;height:34px;line-height:12px;font-size:11px;text-decoration:none;overflow:hidden;text-overflow:ellipsis;" href="http://your_site.com/for-sale/animals/15-rooms-villa-in-bremen_i27">In ancient Roman architecture a villa was originally a country house built for the élite. Pliny the Elder, writing in the first century CE, identified...</a></div>', 'http://your_site.com/oc-content/plugins/radius_search/img/marker-red.png'] 
 
]; 
 

 

 
function setMarkers(map, markers) { 
 
    var gmarkers = []; 
 
    for (var i = 0; i < markers.length; i++) { 
 
    var sites = markers[i]; 
 
    var siteLatLng = new google.maps.LatLng(sites[1], sites[2]); 
 
    var marker = new google.maps.Marker({ 
 
     position: siteLatLng, 
 
     map: map, 
 
     title: sites[0], 
 
     html: sites[3] 
 
     /*, 
 
        icon: sites[4] */ 
 
    }); 
 

 
    var contentString = "Related items"; 
 

 
    google.maps.event.addListener(marker, "click", function() { 
 
     infowindow.setContent(this.html); 
 
     infowindow.open(map, this); 
 
    }); 
 
    } 
 
    return gmarkers; 
 
}
html, 
 
body, 
 
#map_radius_canvas { 
 
    height: 100%; 
 
    width: 100%; 
 
    margin: 0px; 
 
    padding: 0px 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
<script src="https://maps.googleapis.com/maps/api/js?v=3"></script> 
 
<script src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer.js"></script> 
 
<div id="map_radius_canvas"></div>

+0

感谢您的帮助,我已经测试你的代码,并不能得到结果,我希望(它作为我的默认地图)。我想要的就像在谷歌API示范:http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/examples/advanced_example.html – Miso 2015-05-12 08:32:11