-
FEATURED COMPONENTS
First time here? Check out the FAQ!
i have added the google map on my website using javascript, it works well with multiple markers but when i pass the array for infowindow from zscript to javascript it displays white screen..
i want to see this code too
ok... here is the code... <zk> <window id="map"> <zscript> ; import java.lang.; import java.sql.*;
controller con=new controller();
List myArrayList1=new ArrayList();
List myArrayList2=new ArrayList();
List myArrayList3=new ArrayList();
myArrayList1= con.lat_data();
myArrayList2=con.lang_data();
myArrayList3= con.map_info();
// int p=10;
public void sql_con()
{
System.out.println("latitude from map"+myArrayList1);
System.out.println("latitude from map"+myArrayList2);
}
]]>
</zscript>
<html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/> <title></title> <style> body
{
font-family: sans-serif;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script src="../src/maplabel-compiled.js"></script>
<script>
function init() {
var myLatlng = new google.maps.LatLng(21.00,78.00);
var myOptions = {
zoom: 5,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById('map'), myOptions);
var po_lat=${myArrayList1};
var po_lang=${myArrayList2};
var sample=${command};
var i;
for ( i = 0; i < po_lat.length; i++)
{
var marker = new google.maps.Marker({
position:new google.maps.LatLng(po_lat[i],po_lang[i]),
map: map,
});
marker.content=sample[i];
var infowindow = new google.maps.InfoWindow();
google.maps.event.addListener(marker, 'mouseover', (function(marker) {
return function() {
infowindow.setContent(marker.content);
infowindow.open(map, marker);
}
})(marker));
}
}
google.maps.event.addDomListener(window, 'load', init);
</script>
</head> <body>
</body> </html> ]]> </html> </window> </zk>You can't use java object in javascript function directly. Please use zkgmaps component instead.
Asked: 2015-05-26 12:25:10 +0800
Seen: 24 times
Last updated: May 29 '15