我必须根据返回给我的SQL数据添加多个标记放置在Google Maps API上。代码工作正常我调试它并且它正在添加标记到地图但它不可见。它没有在Firebug中显示任何错误,也没有在后端控制台(asp.net)中显示任何错误。请帮助我,让我感到沮丧,就像疯了一样。
function initialize() {
var mapOptions = {
zoom: 16,
center: new google.maps.LatLng(30.658354982307571, -96.396270512761134),
disableDefaultUI: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),
mapOptions);
init_publicmap();
var iconBase = '/WebContent/Images/IconsBase/';
var iconHoneyBees = {
url: iconBase + "honeybeesicon.JPG", // url
scaledSize: new google.maps.Size(35, 40), // scaled size
origin: new google.maps.Point(0, 0), // origin
anchor: new google.maps.Point(0, 0) // anchor
};
var iconFruitNuts = {
url: iconBase + "fruits&nuts.JPEG", // url
scaledSize: new google.maps.Size(35, 40), // scaled size
origin: new google.maps.Point(0, 0), // origin
anchor: new google.maps.Point(0, 0) // anchor
};
var iconForageGrass = {
url: iconBase + "Forage_Grass.JPG", // url
scaledSize: new google.maps.Size(35, 40), // scaled size
origin: new google.maps.Point(0, 0), // origin
anchor: new google.maps.Point(0, 0) // anchor
};
var iconFieldCrops = {
url: iconBase + "FieldCrops.png", // url
scaledSize: new google.maps.Size(35, 40), // scaled size
origin: new google.maps.Point(0, 0), // origin
anchor: new google.maps.Point(0, 0) // anchor
};
var iconNurseryGreen = {
url: iconBase + "Nursery_Greenhouse.JPG", // url
scaledSize: new google.maps.Size(35, 40), // scaled size
origin: new google.maps.Point(0, 0), // origin
anchor: new google.maps.Point(0, 0) // anchor
};
var iconVegetable = {
url: iconBase + "vegetable.png", // url
scaledSize: new google.maps.Size(35, 40), // scaled size
origin: new google.maps.Point(0, 0), // origin
anchor: new google.maps.Point(0, 0) // anchor
};
var icons = {
"Vegetables": {
icon: iconVegetable
},
"Greenhouse and Nursery": {
icon: iconNurseryGreen
},
"Field Crops": {
icon: iconFieldCrops
},
"Fruits and Nuts": {
icon: iconForageGrass
},
"Forage, Grassland": {
icon: iconFruitNuts
},
"Honeybees": {
icon: iconHoneyBees
}
};
function addMarker(feature) {
var marker = new google.maps.Marker({
position: feature.pos,
icon: icons[feature.type].icon,
map: map
});
return marker;
}
//createPolygons(map);
function init_publicmap() {
PageMethods.QueryProducers("All", "All", QueryProducers_Success, Fail);
}
function customfeature(lat, long, type) {
this.type = type;
this.pos = new google.maps.LatLng(lat, long);
}
function QueryProducers_Success(val) {
var featuresloc = JSON.parse(val[1]);
var infowindow = new google.maps.InfoWindow();
for (var i = 0; i < featuresloc.length; i++) {
var customfeatureloc = new customfeature();
customfeatureloc.type = featuresloc[i].croptype;
customfeatureloc.pos = new google.maps.LatLng(featuresloc[i].lat, featuresloc[i].long);
var marker = addMarker(customfeatureloc, map);
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(featuresloc[i].cropname);
infowindow.open(map, marker);
}
})(marker, i));
}
}
function Fail(val) {
}
}
请让我知道我哪里错了.. !!