Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Showing Google map in the browser widget(Problems loading a google map in a browser widget)
Showing Google map in the browser widget [message #481193] Thu, 20 August 2009 05:29 Go to next message
Trevor Campbell is currently offline 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 #481428 is a reply to message #481193] Thu, 20 August 2009 22:58 Go to previous messageGo to next message
Trevor Campbell is currently offline Trevor Campbell
Messages: 23
Registered: July 2009
Junior Member
Workaround:

This all works as advertised if I set the URL to a file that exists,
rather than using setText.

BTW. I am using Firefox on Linux.
Re: Showing Google map in the browser widget [message #481939 is a reply to message #481193] Mon, 24 August 2009 18:51 Go to previous messageGo to next message
Grant Gayed is currently offline Grant Gayed
Messages: 2151
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>
>
Re: Showing Google map in the browser widget [message #481973 is a reply to message #481939] Mon, 24 August 2009 22:53 Go to previous message
Trevor Campbell is currently offline Trevor Campbell
Messages: 23
Registered: July 2009
Junior Member
Thanks, Yes I am using Eclipse 3.5
Previous Topic:animated images require no separate thread
Next Topic:Eclipse properties view throws SWTError
Goto Forum:
  


Current Time: Thu Oct 02 12:26:57 GMT 2014

Powered by FUDForum. Page generated in 0.11519 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software