calling javascript to plot google map in OnInit and OnRecord

Hi, I hope someone can assist. I have been waiting on scriptcase support for more than an hour and I logged a ticket. What I want to do is the following:

In a grid application in OnInit event I create a google map in a div. It displays just fine.
In the OnRecord event I want to plot each row on the map. This does not work. Can anyone tell me why? My code below:

OnInit:
[i]?>
<div id=“map” style=“position: fixed; top:0px; left:0px;width:100%; height:400px”></div>

<script
src=“http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAvqogk-ejNXwcU7sQl7hXPhQLOCCC-Gb74jI7LDiywbGIadtwLhSpjwpXM5Oe3iK6x61ALIxaM17xsQ"type="text/javascript”>
</script>

<script type=“text/javascript”>

////map
var map = new GMap2(document.getElementById(“map”));
map.setCenter(new GLatLng(-32.145386,115.706978), 11);
map.setUIToDefault();
map.addControl(new GMapTypeControl(1));
map.addControl(new GLargeMapControl());
map.addOverlay(geoxml);
map.enableContinuousZoom();
map.enableDoubleClickZoom();

// “tiny” marker icon
var icon = new GIcon();
icon.image = “http://labs.google.com/ridefinder/images/mm_20_red.png”;
icon.shadow = “http://labs.google.com/ridefinder/images/mm_20_shadow.png”;
icon.iconSize = new GSize(12, 20);
icon.shadowSize = new GSize(22, 20);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(5, 1);

var blueicon = new GIcon();
blueicon.image = “http://labs.google.com/ridefinder/images/mm_20_blue.png”;
blueicon.shadow = “http://labs.google.com/ridefinder/images/mm_20_shadow.png”;
blueicon.iconSize = new GSize(12, 20);
blueicon.shadowSize = new GSize(22, 20);
blueicon.iconAnchor = new GPoint(6, 20);
blueicon.infoWindowAnchor = new GPoint(5, 1);

function addMarker(longitude, latitude, description) {
var marker = new GMarker(new GLatLng(latitude, longitude));
GEvent.addListener(marker, ‘click’,
function() {
marker.openInfoWindowHtml(description);
}
);
map.addOverlay(marker);
alert(“xxx”);
}

</script>

<?php
[/i]

OnRecord:
[i]?>

<script type=“text/javascript”>

<?php
echo(“var gpslat = {latitude};”);
echo(“var gpslong = {longitude};”);
echo("var usertype = " . “’” . {tipe} . “’;”);
echo("var gridx = " . “’” . {grid} . “’;”);
?>

alert(“hello”);
addMarker(gpsLat, gpsLong, gridx);
</script>

<?php
[/i]

Re: calling javascript to plot google map in OnInit and OnRecord

Update: the code below plots the markers like I want them, however, when I click on ANY of the markers it always zooms to the last marker added. Any ideas?

OnRecord:
[i]?>
<script type=“text/javascript”>

<?php
echo(“var gpslat = {latitude};”);
echo(“var gpslong = {longitude};”);
echo("var usertype = " . “’” . {tipe} . “’;”);
echo("var gridx = " . “’” . {grid} . “’;”);
?>

var point = new GLatLng(gpslat, gpslong);
if (usertype != ‘Commercial’) {
var markerD = new GMarker(point, {icon:blueicon, draggable: false});
map.addOverlay(markerD);
} else {
var markerD = new GMarker(point, {icon:icon, draggable: false});
map.addOverlay(markerD);
}
GEvent.addListener(markerD, “click”, function() {
markerD.openInfoWindowHtml(gridx);
return false;
});

</script>
<?php[/i]

Re: calling javascript to plot google map in OnInit and OnRecord

If you try this code in a ‘blank’ app in SC5, does it behave the same, or of you create a simple PHP file and run, how does it act. This will tell you if are fighting G-API or SC5.

Regards,
Scott.

Re: calling javascript to plot google map in OnInit and OnRecord

Take a look on this example: http://www.scriptcase.net/forum_en_us/index.php?topic=989.0