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 01:29 Go to previous 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>
 
Read Message
Read Message
Read Message
Read Message
Previous Topic:animated images require no separate thread
Next Topic:Eclipse properties view throws SWTError
Goto Forum:
  


Current Time: Wed May 22 12:03:42 EDT 2013

Powered by FUDForum. Page generated in 0.01873 seconds