[aida] Javascripts
Janko Mivšek
janko.mivsek at eranova.si
Tue Oct 2 18:23:32 CEST 2007
Hi Dirk,
Dirk Verleysen wrote:
> I want to display a googlemap. I need some javascript in my code.
> The first line is this one:
>
> <script type="text/javascript"
> src="http://maps.google.com/maps?file=api&v=2&key=myKeyxxxx"></script>
yourApp addLinkToJavascript:
'http://maps.google.com/maps?file=api&v=2&key=myKeyxxxx'
See this and similar methods in WebPage header elements. WebPage is
superclass of WebApplipaction.
> Then there is this javascript code that I need in the html file. I tried
> putting it in an external file but this didn’t work.
As every WebElement can have a script before and after itself, the same
goes with WebPage as a sublclass of WebElement too. So, try this and
look in a generated html if it is ok:
1. put that script as a text in a method, say #onLoadScript . Note that
you need to change Javascript's $' with two '' so that Smalltalk parser
will accept it.
YourApp>>onLoadScript
^'
//<![CDATA[
function load() { ...}
'
2. in yourApp:
self scriptBefore: self onLoadStript
self onLoad: 'load()'; onUnload='GUnload()'
3. There is no onLoad: and onUnload: methods yet in WebPage, but that is
simple to add - just follow the pattern from, say, WebElement onClick:
WebPage>>onLoad: aJavascriptCode (in events)
self attributesAt: #onLoad add: aJavascriptCode
I hope this help. Let me know the result to add this in next version of
Aida.
Best regards
Janko
> <script>
>
> //<![CDATA[
>
> function load() {
>
> if (GBrowserIsCompatible()) {
>
> var map = new GMap2(document.getElementById("map"));
>
> var geocoder = null;
>
> var trafficInfo = new GTrafficOverlay();
>
> map.setCenter(new GLatLng(50.968580,4.073543,0), 15);
>
> map.addControl(new GSmallMapControl());
>
> map.addControl(new GMapTypeControl());
>
> geoCode = new GClientGeocoder();
>
> var encodedPolyline = new GPolyline.fromEncoded({
>
> color: "#09E466",
>
> weight: 10,
>
> points: "gxavHgvzW{GiItCwElAbD_ na h@lC`Eq na tC",
>
> levels: "BBBBBBB",
>
> zoomFactor: 32,
>
> numLevels: 4
>
> });
>
> map.addOverlay(encodedPolyline);
>
> } }
>
> function showAddress(address) {
>
> geocoder.getLatLng(
>
> address,
>
> function(point) {
>
> if (!point) {
>
> alert(address + " not found");
>
> } else {
>
> map.setCenter(point, 13);
>
> var marker = new GMarker(point);
>
> map.addOverlay(marker);
>
> marker.openInfoWindowHtml(address);
>
> }
>
> }
>
> );
>
> }
>
> //]]>
>
> </script>
>
>
>
> The <body> tag also needs the onLoad=”load()” onUnload=”GUnload()”.
>
>
>
> What’s the best way to deal with this ?
>
>
>
> Dirk
>
>
>
>
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Aida mailing list
> Aida na aidaweb.si
> http://lists.aidaweb.si/mailman/listinfo/aida
--
Janko Mivšek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
More information about the Aida
mailing list