I followed the documentation on Google itself regarding the Map API and other sources to try to figure out what's wrong but after a few hours of trying it still doesnt work..
Could anyone please guide me into solving it?
<div class="generatedMap"></div>
<div class="generatedMap"></div>
<script src="//maps.googleapis.com/maps/api/js?v=3&client=gme-KEYFROMGOOGLEAPI" type="text/javascript"></script>
<script type="text/javascript">
function initMap() {
/*var latlng = new google.maps.LatLng(latitude, longitude);
var mapOptions = {
zoom: 5,
center: new google.maps.LatLng(latitude, longitude)
}
map = new google.maps.Map(document.getElementById('generatedMap'), mapOptions);*/
var latitudeHF = document.getElementById("<%=HF_Latitude.ClientID %>");
var longitudeHF = document.getElementById("<%=HF_Longitude.ClientID %>");
var latitude = 0.0;
var longitude = 0.0;
if (latitudeHF)
{
latitude = latitudeHF.value;
}
if (longitudeHF) {
longitude = longitudeHF.value;
}
var map = new google.maps.Map(document.getElementById('generatedMap'), {
zoom: 8,
center: new google.maps.LatLng(latitude, longitude),
mapTypeId: google.maps.MapTypeId.SATELLITE
});
var marker = new google.maps.Marker({
position: new google.maps.LatLng(latitude, longitude),
map: map,
title: "<div style = 'height:60px;width:150px'><b>Consumer's location:</b><br />Latitude: " + latitude + "<br />Longitude: " + longitude
});
}
google.maps.event.addDomListener(window, 'load', initMap);
</script>
I'm actually retrieving the saved latitude and longitude from my database, then storing it into a HiddenField and retrieving it from there..
foreach (DataRow r in ds.Tables[0].Rows)
{
accountDB = r["AccountStatus"].ToString();
latitudeDB = Convert.ToDouble(r["Latitude"]);
longitudeDB = Convert.ToDouble(r["Longitude"]);
usernameDB = r["Username"].ToString();
ipDB = r["IPAddressOfCreation"].ToString();
}
HF_Latitude.Value = latitudeDB.ToString();
HF_Longitude.Value = longitudeDB.ToString();
I removed the Google Map API key for illustration purposes..
I got both the latitude and longitude displayed as shown in the picture but i cant seem to display the map..
Appreciate any help please!
