Showing Google map in the browser widget [message #481193] |
Thu, 20 August 2009 05:29 |
Trevor Campbell Messages: 23 Registered: July 2009 |
Junior Member |
|
|
I have some code that uses browser.setText(myScript) to load a page in to the browser widget. The script has a small page with one <div> and the necessary code to init the google maps api. I then want to call a js function to set the location (setLocation below).
This works if I do the 2 things in 2 separate actions with a couple of seconds between, but if I try to run them in the same action, it doesn't work. I have tries using the addProgressListener() but the page load seems to finish without the scripts being dowloaded and run. I have alse tried a Thread.sleep(5000), but nothing seems to help?
<!DOCTYPE xhtml PUBLIC "-//W3C//DTD XHTML 4.01//EN">
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Airport view with google maps</title>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">
var map;
function setLocation(lat, long) {
var latlng = new google.maps.LatLng(lat, long);
var myOptions = {
zoom: 14,
center: latlng,
mapTypeId: google.maps.MapTypeId.SATELLITE,
disableDefaultUI: false
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
</script>
<style type="text/css">
*, html { margin:0; padding:0 }
div#map_canvas { width:100%; height:100%; }
}
</style>
</head>
<body>
<div id="map_canvas"></div>
</body>
</html>
|
|
|
|
Re: Showing Google map in the browser widget [message #481939 is a reply to message #481193] |
Mon, 24 August 2009 18:51 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi Trevor,
Doing the browser.execute() in a ProgressListener.completed() implementation
is the correct way to do this, but it's not working for you as a result of
https://bugs.eclipse.org/bugs/show_bug.cgi?id=278370 (I assume you're using
eclipse/swt 3.5). This is fixed in the 3.5.1 stream, and 3.5.1 should be
released by the end of September.
Grant
"Trevor Campbell" <trevor@imprezzeo.com> wrote in message
news:h6imva$6lj$1@build.eclipse.org...
> I have some code that uses browser.setText(myScript) to load a page in to
the browser widget. The script has a small page with one <div> and the
necessary code to init the google maps api. I then want to call a js
function to set the location (setLocation below).
>
> This works if I do the 2 things in 2 separate actions with a couple of
seconds between, but if I try to run them in the same action, it doesn't
work. I have tries using the addProgressListener() but the page load
seems to finish without the scripts being dowloaded and run. I have alse
tried a Thread.sleep(5000), but nothing seems to help?
>
>
> <!DOCTYPE xhtml PUBLIC "-//W3C//DTD XHTML 4.01//EN">
> <html>
> <head>
> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
> <title>Airport view with google maps</title>
>
> <script type="text/javascript"
> src="http://maps.google.com/maps/api/js?sensor=true"></script>
>
> <script type="text/javascript">
> var map;
>
> function setLocation(lat, long) {
> var latlng = new google.maps.LatLng(lat, long);
> var myOptions = {
> zoom: 14,
> center: latlng,
> mapTypeId: google.maps.MapTypeId.SATELLITE,
> disableDefaultUI: false
> }
> map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
> }
>
> </script>
>
> <style type="text/css">
> *, html { margin:0; padding:0 }
> div#map_canvas { width:100%; height:100%; }
> }
> </style>
>
> </head>
> <body>
> <div id="map_canvas"></div>
> </body>
> </html>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03144 seconds