All my multiple marker is showing the last business name. I am trying
to have dynamic information with each marker. What am I doing wrong?
<html>
<head>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/
libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript"
src="http://maps.google.com/maps/api/
js?sensor=false"></script>
<script type="text/javascript" src="http://www.tantik.com/
infobox.js"></script>
<script type="text/javascript" src="http://www.tantik.com/
markerwithlabel.js"></script>
<script type="text/javascript">
$(document).ready(
function(){
//alert("JS YO!");
var marker = [];
//var params = [];
$(".mapblock").each(function (i){
//alert( $(this).html());
marker[i] = [7];
params = ($(this).html()).split("|");
//alert(params);
marker[i][0]= params[0];
marker[i][1] = params[1];
marker[i][2] = params[2];
marker[i][3]= params[3];
marker[i][4] = params[4];
marker[i][5]= params[5];
marker[i][6] = params[6];
marker[i][7]= params[7];
});
//alert(marker);
buildmap(marker);
}
);
//running the map function
function buildmap(spots){
var myOptions = {
zoom: 12,
center: new google.maps.LatLng(spots[0][0],
spots[0][1]),
mapTypeId: google.maps.MapTypeId.HYBRID
};
var map = new
google.maps.Map(document.getElementById("dealermap"),myOptions);
var markers = [];
for(var i=0; i < spots.length; i++){
var dealer = spots[i];
var dealerLatLong = new
google.maps.LatLng(dealer[0], dealer[1]);
if(dealer[9] > 9){
x = 8;
}else{
x = 4;
}
var marker = new MarkerWithLabel({
position: dealerLatLong,
map: map,
//icon: image,
//labelContent: i,
labelAnchor: new google.maps.Point(x,
30),
labelClass: "labels", // the CSS class
for the label
labelInBackground: false,
//zIndex:i
});
//markers[i] = marker;
contentString = dealer[2];
var options = {
content: contentString
,disableAutoPan: false
,maxWidth: 0
,pixelOffset: new
google.maps.Size(-159, -230)
,zIndex: null
,boxStyle: {
background: "#fff no-repeat"
,border: "3px solid #E65417"
,opacity: 1
,width: "308px"
,height: "188px"
}
,closeBoxMargin: "2px 2px 2px 2px"
,closeBoxURL:
"http://www.google.com/intl/en_us/mapfiles/
close.gif"
,infoBoxClearance: new
google.maps.Size(1, 1)
,isHidden: false
,pane: "floatPane"
};
var ib = new InfoBox(options);
google.maps.event.addListener(marker, 'click',
(function(marker,
i) {
return function() {
ib.open(map, marker);
}
})(marker, i));
}
}
</script>
</head>
<body>
<div class="mapblock">36.91190|-76.21320|Bay Chevrolet Saab
Kia|6970
N. Military Hwy.|Norfolk|VA|23518|757-855-5555</div>
<div class="mapblock">36.88940|-76.23820|Enterprise|2630
Wyoming Ave|
Norfolk|VA|23513|757-855-6720</div>
<div class="mapblock">36.91190|-76.21320|Green Gifford|2747 N.
Millitary Hwy|Norfolk|VA|23518|757-284-3418</div>
<div class="mapblock">36.75220|-76.21680|Greenbrier Chrysler
Jeep|
1414 South Military Highway|Chesapeake|VA|23320|888-559-6530</div>
<div class="mapblock">36.75220|-76.21680|Greenbrier Pontiac GMC
Kia|
1300 S. Military Highway|Chesapeake|VA|23320|888-598-8968</div>
<div class="mapblock">36.75220|-76.21680|Greenbrier
Volkswagen|1248
S. Military Highway|Chesapeake|VA|23320|888-659-3562</div>
<div class="mapblock">36.75220|-76.21680|Greenbrier Wholesale
Center|
1510 S. Military Highway|Chesapeake|VA|23320|888-876-4139</div>
<div class="mapblock">36.85650|-76.21180|Kimnach Ford|6401 E.
Virginia Beach Blvd.|Norfolk|VA|23502|757-461-6401</div>
<div class="mapblock">36.85650|-76.21180|Perry Buick Pontiac
Subaru|
6633 Virginia Beach Blvd|Norfolk|VA|23502|757-461-8855</div>
<div class="mapblock">36.83760|-76.15100|Phillips Mercedes Land
Rover|4949 Virginia Beach Blvd.|Virginia Beach|VA|23462|800-601-3644</
div>
<div id="dealermap" style="width:770px;height:500px;border:1px
solid
#ddd;"></div>
</body>
</html>
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.