Jump to content

google and javascript problems inside my app help


Champak
 Share

Recommended Posts

Im trying to get the traffic to update in this script. it works fine outside of autoit, but when I try to merge the two, I cant get it to work. My first issue is I cant get the map to show properly when I broke it down to its bare essentials for this test and its really late and cant make anything out right now. The second problem is the interval isn't repeating in the javascript once incorporated in my script.

Here is the javascript in its pure html form: http://jsfiddle.net/nnh3ka3o/ (you may want to change the gps coordinates to a more active location)

Here it is in autoit

#include <IE.au3>
Local $html1c = _"<!DOCTYPE html>" & @CRLF & _
"<html>" & @CRLF & _
"<head>" & @CRLF & _
"   <title>Google Maps</title>" & @CRLF & _
"   <style type='text/css'>" & @CRLF & _
"       #map_canvas { height: 100%; width: 100%; }" & @CRLF & _
"   </style>" & @CRLF & _
"    <script type=""text/javascript"" src=""http://maps.googleapis.com/maps/api/js?sensor=false&libraries=geometry,places,weather&language=" & StringLower("EN") & """></script>" & @CRLF & _
"   <script type='text/javascript'>" & @CRLF & _
"   function initialize() {" & @CRLF & _;======================================
"       var myLatlng = new google.maps.LatLng(41.88217,-73.67884);" & @CRLF & _
"       mapOptions = {" & @CRLF & _
"           zoom: 15," & @CRLF & _
"           center: myLatlng" & @CRLF & _
"       }" & @CRLF & _
"       map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);   " & @CRLF & _
"       trafficLayer = new google.maps.TrafficLayer();" & @CRLF & _
"       trafficLayer.setMap(map);" & @CRLF & _
"       setInterval(reloadTiles,    5000);" & @CRLF & _"    }" & @CRLF & _
"   function reloadTiles() {" & @CRLF & _;======================================="      alert(""12345"");" & @CRLF & _
"       var tiles = $('#map_canvas').find('img');" & @CRLF & _
"       for (var i = 0; i < tiles.length; i++) {" & @CRLF & _
"           var src = $(tiles[i]).attr('src');" & @CRLF & _
"           if (/googleapis.com\/vt\?pb=/.test(src)) {" & @CRLF & _
"               var new_src = src.split('&ts')[0] + '&ts=' + (new Date()).getTime();" & @CRLF & _
"               $(tiles[i]).attr('src', new_src);" & @CRLF & _
"           }" & @CRLF & _
"       }" & @CRLF & _
"   }" & @CRLF & _
"   </script>" & @CRLF & _
"   </head>" & @CRLF & _
"       <body style=""margin:0px; padding:0px;"" onload=""initialize();"">" & @CRLF & _
"           <div id='map_canvas'></div>" & @CRLF & _
"       </body>" & @CRLF & _
"   </html>"    
Dim $html = $html1c 
$gmap = _IECreateEmbedded() 
GUICreate("Test", 640, 480, 100, -700)  
$gmap_ctrl = GUICtrlCreateObj($gmap, 10, 10, 640, 480)  
GUISetState(@SW_SHOW) ;Show 
GUI _IENavigate($gmap, "about:blank", 1)
_IEDocWriteHTML($gmap, $html)   
_IEAction ($gmap, "refresh")
While 1 
Sleep(100)
    WEnd
Any help please. Edited by Champak
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...