I am using this code to get the google map.it has the lat and lon value, but i have a database which has lat and lon. i want to use the lat and lon from database in this map,how to do this?
this is my google map javascript
<script type="text/javascript">
function initialize() {
var latlng = new google.maps.LatLng(12.91869,77.594051);
var myOptions = {
zoom: 12,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map,
});
var infowindow = new google.maps.InfoWindow({
map: map,
position: latlng,
});
map.openInfoWindow(latlng,
document.createTextNode("Hello, world"));
}
</script>
Can anyone help me…?
Thanks in advance…..
Just a method you can follow to go ahead-
Firstly load the latlng values from the database and store them in an array.
Then pass this array of latlng’s to a javascript function that will display this latlng values on the map. The function will essentially contain a loop that will display each of these latlng’s one by one on the map along with a marker.
You should first try working with an array of latlng’s hardcoded in an array of javascript. Then it would be easy dealing with values retrieved from a database.