I have only recently begun to play around with html, javascript, webapps etc and I decided to try write my own Prey standalone webserver.
I am using Twitter Bootstrap for the UI, and jQuery for javascript stuff. My reports page lists all the reports and allows the user to select one to view on the map. The page then gets the data as JSON from the server which all works fine. However when I call map.setCenter(new google.maps.LatLng(data['lat'], data['lng'])) the map just turns grey instead of moving to that location.
I have tried this in chrome and firefox, and I get the same problem. Strangely, there are no errors in the chrome console-debugger-thing nor in firebug. I can see maybe 10 similar issues under “Similar Questions”; however none of those solutions (eg. CSS) have helped.
Here’s the website (it’s a sandbox on dotCloud, so it might be very slow): http://prey-geniass.dotcloud.com/devices/l6wyd/reports.xml
So I noticed you store the map object as
window['map'](funny how everybody seems to do that… makes debugging easier when I don’t have to dive into the source 🙂 ).I tried to set the centre myself using a known set of coordinates:
This worked fine, so the actual code is working fine. I tested some cases for incorrect values…
nulland0would put me somewhere in the ocean, butundefinedfor bothlatandlngwould turn the map grey. Perhaps the values you are passing in are incorrect, and end up beingundefined?Looking at the second
alertthat comes, the relevant properties arelatitudeandlongitude, although you seem to be passing indata['lat']anddata['lng']. Would this be the reason?This should fix it:
Please note that I commented out your ‘resize’ trigger (which I assume you probably added in an effort to resolve this problem? I remember suggesting that to another user here :)). It is not required in your case.