Javascripts

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Javascripts

Dirk Verleysen
New question but I first want to thank Nicholas and Janko for their
answers.

 

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&amp;v=2&amp;key=myKeyxxxx"></s
cript>

 

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.

  <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_ op h@lC`Eq op 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
 
 

 

 

 

------------- volgend deel ------------
Een HTML-bijlage is verwijderd...
URL: http://lists.aidaweb.si/pipermail/aida/attachments/20071002/66086808/attachment.htm 

Reply | Threaded
Open this post in threaded view
|

Javascripts

Nicholas Moore
I show a google map in a cell  like this (with no external file):

    (e newCell)
    addBreak;
        align: #center;
        addText: '
<iframe width="240" height="180" frameborder="0" scrolling="no"
marginheight="0" marginwidth="0"
src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;om=1&amp;s=AARTsJpOU76BOuLx9Iv9OiWPoYlz06tHfQ&amp;msa=0&amp;msid=105741824393007908646.000001127bc850ee303ef&amp;ll=45.864194,1.329346&amp;spn=0.172135,0.32959&amp;z=10&amp;output=embed"></iframe><br
/><small><a
href="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;om=1&amp;msa=0&amp;msid=105741824393007908646.000001127bc850ee303ef&amp;ll=45.864194,1.329346&amp;spn=0.172135,0.32959&amp;z=10&amp;source=embed"
style="color:#0000FF;text-align:left">View Larger Map</a></small>'.

Works fine. This is a map I have created through a google account first.

Nicholas

Dirk Verleysen wrote:

>
> New question but I first want to thank Nicholas and Janko for their
> answers.
>
>  
>
> 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&amp;v=2&amp;key=myKeyxxxx"></script>
>
>  
>
> 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.
>
>   <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_ at h@lC`Eq at 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 at aidaweb.si
> http://lists.aidaweb.si/mailman/listinfo/aida
>  


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.aidaweb.si/pipermail/aida/attachments/20071002/3405e877/attachment-0001.htm 

Reply | Threaded
Open this post in threaded view
|

Javascripts

Janko Mivšek
In reply to this post by Dirk Verleysen
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&amp;v=2&amp;key=myKeyxxxx"></script>

yourApp addLinkToJavascript:
   'http://maps.google.com/maps?file=api&amp;v=2&amp;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

Reply | Threaded
Open this post in threaded view
|

Javascripts

Dirk Verleysen
Janko,

Your examples work perfectly. I've added the onLoad: and onUnload: to WebPage and it does what I want.

Thanks.. (you to Nicolas).

Dirk

-----Oorspronkelijk bericht-----
Van: aida-bounces op aidaweb.si [mailto:aida-bounces op aidaweb.si] Namens Janko Miv?ek
Verzonden: dinsdag 2 oktober 2007 18:24
Aan: AIDA/Web general discussion list
Onderwerp: Re: [aida] Javascripts

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&amp;v=2&amp;key=myKeyxxxx"></script>

yourApp addLinkToJavascript:
   'http://maps.google.com/maps?file=api&amp;v=2&amp;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_ op h@lC`Eq op 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 op aidaweb.si
> http://lists.aidaweb.si/mailman/listinfo/aida

--
Janko Miv?ek
AIDA/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
Aida op aidaweb.si
http://lists.aidaweb.si/mailman/listinfo/aida