Greatings,
I'm using APEX R5. I've coded a PL/SQL process that loops through a table and puts multiple Markers on a Google Map. All of the code works fine except for the Info Window. (The Marker Title displays correctly.) ALL of the Info Windows display the SAME data from one row of data. What am I doing wrong? I think I'm completely missing an aspect. I've moved the Info Window code to different parts of the process, but nothing solved this problem. (I'm not a JavaScript or Google Maps expert, any help is appreciated.)
Thanks in advance, Tony
= = = = = = =
DECLARE
BEGIN
htp.p('<script type="text/javascript">');
htp.p('
function initialize() {
var myOptions = {
zoom: 8 ,
center: new google.maps.LatLng(38.5,-75.5),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"),myOptions);
');
FOR import IN ( select * from sienareports_v5.outage_history
where (
to_date(reportTime) between NVL(to_date(:P10_FROM_DATE_SEARCH,'MM/DD/RRRR HH24:MI'), reportTime)
and NVL(to_date(:P10_TO_DATE_SEARCH,'MM/DD/RRRR HH24:MI'), reportTime)
and ((:P10_CAUSE_INVALID_YN = 'N' and causeName <> 'Invalid') or (:P10_CAUSE_INVALID_YN = 'Y'))
and (:P10_OUTAGEID IS NULL)
and (substation = nvl(:P10_SUBSTATION, substation))
and (causeid||'-'||causename = nvl(:P10_CAUSE, causeid||'-'||causename))
)
or
(
outageId = nvl(:P10_OUTAGEID, outageId) and :P10_OUTAGEID IS NOT NULL
) )
LOOP
htp.p('
var latlng = new google.maps.LatLng('||apex_javascript.add_value(SUBSTR(import.outage_lat_lng, 1, INSTR(import.outage_lat_lng, ',') - 1),true)||'+'
||apex_javascript.add_value(SUBSTR(import.outage_lat_lng, INSTR(import.outage_lat_lng, ',') + 1),false)||');
var v_outage = '||apex_javascript.add_value(to_char(import.outageid),false)||';
var v_cause = '||apex_javascript.add_value(import.causeName,false)||';
var v_timeoff = '||apex_javascript.add_value(import.reportTime,false)||';
var v_duration = '||apex_javascript.add_value(to_char(siena_reports.reports_tools.format_duration((import.restoreTime-import.reportTime)*1440)),false)||';
var iw = new google.maps.InfoWindow({
content: "<B>" + v_outage + "</B>" + "<BR>" + v_timeoff + "<BR>" + v_duration
});
var marker = new google.maps.Marker({
position: latlng,
map: map,
title: v_outage
//title: v_outage + " - " + v_timeoff + " - " + v_duration
//title: "<div>" + "<h1>" + v_outage + "</h1>" + "<p><span style=''font-weight:bold;''>Time Off: </span>" + v_timeoff + "</p>" +"</div>"
});
var iw = new google.maps.InfoWindow({
content: "<B>"+v_outage+"</B>" + "<BR>" + v_timeoff + "<BR>" + v_duration
});
google.maps.event.addListener(marker,''click'',function(){
iw.open(map,marker);
//iw.setOptions({content: v_outage + " - " + v_timeoff + " - " + v_duration + "<hr>"});
});
');
END LOOP;
htp.p('
}
');
htp.p('</script>');
END;