Link to home
Start Free TrialLog in
Avatar of bhession
bhession

asked on

Whats wrong with my JSP?

I am trying to use Google Maps Javascript API V3 with my JSP. Now the problem I am having is that

<%=Latitude%>,<%Longitude%> seems to cause an error im my JSP.

I want to create marker for each entry in the Vector, so as the for loop, loopsI want a create a marker on my map. How can I do this?

I have attached my JSP so far.

I dont know javascript so this is proving tricky.
Avatar of bhession
bhession

ASKER

Sorry here is the .jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>Test</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
  html { height: 100% }
  body { height: 100%; margin: 0px; padding: 0px }
  #map_canvas { height: 100% }
</style>
<script type="text/javascript"
    src="http://maps.google.com/maps/api/js?sensor=false">
</script>
<script type="text/javascript">
  function initialize() {
    var latlng = new google.maps.LatLng(53.3, 8.9);
    var myOptions = {
      zoom: 7,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);

  
  }

</script>
</head>
<body onload="initialize()">
<%@ page import="com.google.project.Turbine" %>
<%@ page import="java.util.Vector" %>

<%
Vector<Turbine> turbines = new Vector<Turbine>();
turbines=(Vector<Turbine>)request.getAttribute("turbines");


if (turbines.size()==0){
	System.out.println("No record found matching your search"+"\n");
}
else if(turbines.size()!=0)
	{
for (int i=0; i < turbines.size(); i++)
{
	Turbine turbine = (Turbine)turbines.elementAt(i);

int ID = turbine.getID();
String TurbineSerialNo  = turbine.getTurbineSerialNo();
String ModelNumber = turbine.getModelNumber();
String ControllerSerialNo = turbine.getControllerSerialNo();
String MobileNo = turbine.getMobileNo();
String IMEINo = turbine.getIMEINo();
String AlternatorBNo = turbine.getAlternatorBNo();
String AlternatorCNo = turbine.getAlternatorCNo();
int Owner = turbine.getOwner();
String Address1 = turbine.getAddress1();
String Address2 = turbine.getAddress2();
String Address3 = turbine.getAddress3();
String County = turbine.getCounty();
String Country = turbine.getCountry();
String Northings = turbine.getNorthings();
String Eastings = turbine.getEastings();

double Latitude = Double.parseDouble(Northings);
double Longitude = Double.parseDouble(Eastings);

/*
out.println("<h4><br><b>ID is </b>"+ID
	    +"<br><b>TurbineSerialNo: </b>"+TurbineSerialNo
	    +"<br><b>Model No: </b>"+ModelNumber
	    +"<br><b>Controller Serial No: </b>"+ControllerSerialNo
	    +"<br><b>Mobile No: </b>"+MobileNo
	    +"<br><b>IMEI No: </b>"+IMEINo
	    +"<br><b>Alternator B No: </b+>"+AlternatorBNo
	    +"<BR><B>Alternator C No: </B>"+AlternatorCNo
	    +"<BR><B>Owner: </B>"+Owner
	    +"<BR><B>Address: </B>"+Address1+","+Address2+","+Address3+","+County+","+Country
	    +"<BR><B>Latitude: </B>"+Northings
	    +"<BR><B>Longitude: </B>"+Eastings);*/
	    

}
out.println("</h4>");

}
%>


  <div id="map_canvas" style="width:100%; height:100%"></div>
  <script type="text/javascript">
  var latlng2 = new google.maps.LatLng(<%=Latitude%>,<%=Longitude%>);
  var marker = new google.maps.Marker({
        position: myLatlng2, 
        map: map,
        title:"Hello World!"
    });   

</script>
  


  </body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of chaitu chaitu
chaitu chaitu
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sathish David  Kumar N
<%Longitude;%>

('<%=Latitude%>','<%=Longitude%>');  
Sorry chaituu: i didnt see ur code
Sorry guys that didnt seem to work either
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I thought this was closed off, my apologies. The above lead to the solution.