Hello!
I need to load a map from data from the database and display in jsp,
this is my code:
<script type="text/javascript" src="
http://maps.google.com/maps/api/js?
sensor=false"></script>
<script type="text/javascript">
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var address = document.getElementById("address").value;
if (geocoder) {
geocoder.geocode( { 'address': address}, function(results, status)
{
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: "
+ status);
}
});
}
var latlng = new google.maps.LatLng(-22.9035393, -43.2095869);
var myOptions = {
zoom: 15,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
}
</script>
</head>
<body id="home" onload="initialize()">
<div id="map_canvas" style="width: 620px; height: 380px;"></div>
<input id="address" type="text" value="${home.address }, ${home.city},
${home.country}">
</div>
<div>
</body>
As you can see, I'm using "Expression Language" to capture the data.
The code is too bad, because it goes to rio de janeiro then go to the
correct address, how do I get direct to the address that is in
Expression Language??
Thanks!!!