我是谷歌地图 api 的新手。我创建了一个以核心值作为标记的地图。但我想用来自数据库的值创建我的标记。这是我的代码
function initialize() {
var map = new google.maps.Map(document.getElementById("map_canvas"), {
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: false
});
var markers = [ // Here I set the hard core values for my markers.
{ lat: 22.64201389, lng: 88.43034722, name: "Airport" },
{ lat: 22.60944444, lng: 88.42694444, name: "Baguihati" },
{ lat: 22.53604167, lng: 88.36083333, name: "Ballygunge Phari" },
{ lat: 22.49895833, lng: 88.31902778, name: "Behala" },
{ lat: 22.65743056, lng: 88.36409722, name: "Dakshineshwar" },
{ lat: 22.62013889, lng: 88.39215278 , name: "Dum-Dum Station." },
{ lat: 22.52111111, lng: 88.36479167, name: "Gariahat" },
{ lat: 22.58763889, lng: 88.34027778, name: "Howrah" },
{ lat: 22.59131944, lng: 88.43291667, name: "Karunamayee East" },
{ lat: 22.52131944, lng: 88.38201389, name: "Kasba Bosepukur" },
{ lat: 22.60256944 , lng: 88.40166667 , name: "Lake Town" },
{ lat: 22.68993056, lng: 88.47569444, name: "Madhyam Gram_East" },
{ lat: 22.50875 , lng: 88.33284722 , name: " New Alipur" },
{ lat: 22.54409722 , lng: 88.36743056, name: "Park circus" },
];
for (index in markers) addMarker(markers[index]);
function addMarker(data) {
new google.maps.Marker({
position: new google.maps.LatLng(data.lat, data.lng),
map: map,
title: data.name
});
}
var bounds = new google.maps.LatLngBounds();
for (index in markers) {
var data = markers[index];
bounds.extend(new google.maps.LatLng(data.lat, data.lng));
}
map.fitBounds(bounds);
请帮我在制造商中设置数据库值。这些值将来自 servlet。