Google Map API Errors - javascript

I'm creating a dynamic map with the Google Maps API and I'm getting hard to understand errors from only certain markers. My page is located at:
http://dmatesic.com/RaC/Customized%20Google%20Map/google_map.html
My (long) java script source file is located at:
http://dmatesic.com/RaC/Customized%20Google%20Map/js/google_map.js
Everything is working fine except for one marker. If you click on "SERVICOS" and then select the sub category "Repuestos de Autos" I am getting odd errors from the google map main.js file.
In Firefox I get:
c is undefined
http://maps.gstatic.com/intl/en_us/mapfiles/193c/maps2.api/main.js
Line 600
In IE:
'x' is null or not an object main.js, line 600 character 83
I have no idea why everything is working except for this one sub category/marker. If there any other details I can provide to help us solve this problem, please let me know.
Any ideas?
Thanks!

you are getting error because getZoomFactor return NaN, and after that you are calling setCenter method with zoom NaN.
This is the line that is causing problem.
zoom = getZoomFactor(minLatitude, maxLatitude, minLongitude, maxLongitude, centerLatitude, centerLongitude, 600);
map.setCenter(centerPoint, zoom);

Related

Bing Maps v8 and strange work of instanceof

Load map:
map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
...
});
And it works fine (visually). But:
console.log(map instanceof Microsoft.Maps.Map); // false
Whaaat?! :) How can I check it? Is it a bug or my mistake?
You can try example in Bing Dev Center sandbox:
http://www.bing.com/api/maps/sdkrelease/mapcontrol/isdk#loadMapAsync+JS
Thanks
Using the Bing Apps dev page, if you edit out the new it still works, and logging map.constructor just prints function n(). So it appears Microsoft has not been entirely accurate as to what the code does at the moment - which is to act as an object factory.
Microsoft may be reserving the right to make Maps.Map an object constructor in the future. At the moment instanceof returning false is correct.

How to retrieve data from spreadsheet for chart google script. (Using HTML Service)

Hey good morning/afternoon/evening depending where you guys are at!
Just have a quick question for you guys. I've been stuck on this for a bit, and I've tried looking around, but i can't seem to find the answer for this specific issue.
So I'm in the process of trying to create a column chart using google scripts with the html service (since they UIApp service is depreciated now). I'm trying to retrieve the data from a spreadsheet have already created. But when i use this code, the page comes up blank as if there is some error in the background.
var sheet = SpreadsheetApp.openById("1gdRB6FFV426bAj95C0xJlqSucnnX0Z5ATVQdC2");
So here are some specifics:
1) I put this line in my Index.html file within a function I have called
drawChart();
2) I do have them wrapped in this tag.
<script type="text/javascript">
3) I know that this line of code is the cause of the issue because as soon as i comment it out my temp graph with temp data pops up, and page runs fine. But as soon as uncommented it blanks out the whole page.
Any ideas?
I'm wondering if I have to actually place this line of code within the "Code.gs" file, then some how transfer the data from Code.gs to my Index.html file. If that's the case can anyone point me in the direction to where I can follow the direction on how to do it?
Thank you guys in advance.
Sincerely,
Sicariuxs
You must use a withSuccessHandler(functionNameToReceiveData).
<script>
function getData() {
google.script.run
.withSuccessHandler(functionNameToReceiveData)
getData();
};
function functionNameToReceiveData(theDateReceivedHere) {
Logger.log('theDateReceivedHere: ' + theDateReceivedHere;
};
</script>
You can't use: var data = google.script.run.getData(); You must use a withSuccessHandler(functionNameToReceiveData).
#Sandy Good
Hey man I want to thank you for all your help. you're answer was actually great. But there was an additional mistake on top of the ones that you corrected me on. In my actual spreadsheet I had it as a "Date" value. But the format was not matching the data type in my "dataTable". It's working now though. I made all the changes you told me, but in addition I changed the value type from "Date" to "Text". Then in my for loop I wrote a "new Date()" function using the text as the format, and that worked here is some screenshots to show my end result.
link
link

Why are my locations undefined and display not updating?

I am having some issues with a class project. Every thing was working fine and dandy up until the current part we are on. Basically, we had to add prototypes and cases to move to each location. Now my code will not work, and the teacher is about as helpful as a pet rock. I have two parts to my code, the html (which has part of the code including items and such) and the .js file that includes the locations.
I have created a repository on Github so it is easily accessible to all who want to help. At this point it is too late to submit to my professor, but I am curious on what I did wrong.
https://github.com/EmeraldX/Project-Help/tree/master
The main and directions.js are the files that I am currently working with.
Thanks!
Update: Okay, so it's still not working, and when I use Chrome's console it just tells me that:
function updateDisplay( message ) {
var textArea = document.getElementById("introduction");
textArea.value = message + "\n\n" + textArea.value;
Cannot read property 'value' of null
I tried opening your html page and js using firefox, and used the firebug consol to see if anything was wrong.
It looks like you have an ) missing in your js:
SyntaxError: missing ) after argument list directions.js:7:145
And it was right:
locations[2] = new Location(2,"Lake","A large lake that is formed by a river flowing from the East.",
new Item(1,"Fish","An old rotting fish.");
is missing a ')'
After correcting it, it appear that you miss this ) line 7, 9, 13 and 14.
Then a new error pop up:
ReferenceError: Item is not defined directions.js:7:2
This can be corrected by calling your direction.js AFTER you js script in main.html.
Hope it can help

Cloud code (javascript) failed wtih: {"code":1,"message":"internal error"}

I'm trying to run the following code:
if(req.query.currentPosition) {
console.log("[DEBUG] My current position: " + req.query.currentPosition);
var maxRadius = 10;
var coordinates = req.query.currentPosition.split(",");
var latitude = parseFloat(coordinates[0]);
var longitude = parseFloat(coordinates[1]);
var point = new Parse.GeoPoint({latitude: latitude, longitude: longitude});
query.withinKilometers("coordinates", point, maxRadius);
}
return query.find({});
where I read some coordinates from the requests query parameters and I pass those onto a query as a geolocation constraint. Whenever the code runs I get the error
{"code":1,"message":"internal error"}
and nothing more specific. If I remove the above code block, I don't have any error at all.
I've done some research, and I have found that some other developers have also stumbled upon this message, though in a different context.
https://www.parse.com/questions/cloud-code-failed-with-code-1message
https://www.parse.com/questions/facebook-login-code-1-internal-error
Yet no satisfying conclusion was reached or provided.
What have I tried so far:
Multiple redeploys (my favourite)
adding and removing the "coordinates" columns
One of the suggestions from the links I found was that it could a parse internal issue, so waited a day or so to see if anything could be magically solved
Added a ridiculously amount of logs to see if I could print anything that it could give me a better description of what was happening
Also checked if anything could be wrong with the data
Compared with other running applications that have the same code block and are working to see what could be wrong.
None of the above proved to be helpful.
SDK Version
Parse JavaScript SDK v1.3.3
Any enlightenment is appreciated.
Cheers.
I just found the problem. I was setting the wrong key when adding the "withinKilometers" constraint.
Cheers

Google Maps Apiv3 + Load map on page load + a is NULL

First of all: The map is working.
The script is in scripts.js, which is included at the bottom of the site.
The Google maps script is included in the header (<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>).
The problem is I am getting this a is NULL error and I would like to fix it, although the map is working fine.
I have searched Google and Stackoverflow and tried every possible combination of the answers I found, but either the map is not working, or the map is working, but I get this a is NULL error error.
Here is the simple demo script I am using for testing:
function init() {
var myOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('resultsGmap'),
myOptions);
}
window.onload=init();
I have tried to use jQuery too like this:
$(function() {
init();
});
But than nothing works at all. I have also tried to do it very simple like this:
init();
Which works (the map works) but the a is NULL error error appears again.
The other thing I tried was:
google.maps.event.addDomListener(window, 'load', init);
But than again the map doesn't display and the error appears.
For various reason I cant do it the way it is in the official example # Google:
<body onload="init()">
Anybody got an idea what I am doing wrong?
Regards and have a good day!
EDIT:
I have just tried to reproduce the error on a blank page and there it doesnt appear - so I guess it is something else in my code (p.s. I am loading the site with the map via ajax and call the script with $.getScript).
Sorry that I didnt check that before. I guess the error lies in there somewhere.
One more thing: Do you guys think it would be very, very bad to just ignore the error? Since the map and every feature is working correctly.
I'm suspecting it has to do with the ID you provide. Is there a (for example) DIV with the ID 'resultsGmap'.
It might have also got to do with the uppercase. Try using lowercase only, optionally with underscores (_)

Categories