mbpowner Posted October 11, 2017 Share Posted October 11, 2017 Link to comment Share on other sites More sharing options...
mbpowner Posted October 11, 2017 Author Share Posted October 11, 2017 Sorry, my question was why the getCurrentLocation() method returns null... Link to comment Share on other sites More sharing options...
justsomeguy Posted October 11, 2017 Share Posted October 11, 2017 I don't see any content in your first post except a blocked request, but I assume that would return null if the user opted to not share their location. Link to comment Share on other sites More sharing options...
mbpowner Posted October 11, 2017 Author Share Posted October 11, 2017 https://codepen.io/CodeCampStart/pen/MvxZbz?editors=1111 Link to comment Share on other sites More sharing options...
mbpowner Posted October 11, 2017 Author Share Posted October 11, 2017 firstly i am getting this error "jQuery.Deferred exception: Can't find variable: google" "https://s.codepen.io/boomerang/iFrameKey-568d6cd1-874a-d6dd-bd79-55f4353f18e0/index.html?editors=1111:239:24 Link to comment Share on other sites More sharing options...
mbpowner Posted October 11, 2017 Author Share Posted October 11, 2017 also this error "Google Maps API warning: InvalidKey https://developers.google.com/maps/documentation/javascript/error-messages#invalid-key" Link to comment Share on other sites More sharing options...
mbpowner Posted October 11, 2017 Author Share Posted October 11, 2017 but i havent used a callback function so i dont really know how to change that as i wish to leave it as it is where it loads as soon as the page is loaded.. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 11, 2017 Share Posted October 11, 2017 I don't see those messages, I see lat and long are undefined. That's probably because the callback won't get called if the user doesn't share their location. You need to check if those variables are defined before trying to do something with them. You can go that Google URL if you want to see information about the error message from them. Link to comment Share on other sites More sharing options...
mbpowner Posted October 11, 2017 Author Share Posted October 11, 2017 Ahh I managed to see the issue was that, for some reason, you need to have a UserCoords object in order to be visible the latitude & longitude globally instead of setting long and lat variables, the variables will be undefined but using an object it works for some odd reason... Anyhow, managed to resolve hte null llocation issue. Other issue is the map won't load. If you click on the settings on the javascript you can see that this is my script src that i have used: https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false not sure why this isn't working... it used to work i'm also not sure why my JSON data isn't working ? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 11, 2017 Share Posted October 11, 2017 I would guess that the map isn't loading because you don't have an API key. At least, according to the URL in the error message. Link to comment Share on other sites More sharing options...
mbpowner Posted October 11, 2017 Author Share Posted October 11, 2017 That's weird because it worked like this, just a few weeks ago. Could you tell me why the JSON data isnt loading please using that api ? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 12, 2017 Share Posted October 12, 2017 If you're talking about openweathermap.org, my browser's console tells me it's because it's an insecure response. That probably means the page was loaded over HTTPS but it's trying to send a request to HTTP and the browser is blocking it. Link to comment Share on other sites More sharing options...
mbpowner Posted October 12, 2017 Author Share Posted October 12, 2017 (edited) 9 hours ago, justsomeguy said: If you're talking about openweathermap.org, my browser's console tells me it's because it's an insecure response. That probably means the page was loaded over HTTPS but it's trying to send a request to HTTP and the browser is blocking it. I figured it was to do with me using the wrong API key. i kinda tried to use an open api key out there, but that failed. that must be something to do with secureness, i suppoe. something has changed lately. but anyways it worked when i created my own api key. anyhow, still working on the google maps... they're just warnings regarding the api key, and was working fine before for sure. now i'm just not sure why it's showing a blue sky instead of land. also my location seems to be showing zagreb, when i'm actually in england. i think this is due to the inaccuracy of the api. i tried using the coordinates and they showed the right place with google... so the coordinates are right... but the sky is, for some reason, displayed on the map. whereas on the google maps website these coordinates display my universtiy Edited October 12, 2017 by mbpowner Link to comment Share on other sites More sharing options...
mbpowner Posted October 12, 2017 Author Share Posted October 12, 2017 By means of further experiment, I found that the api key does not matter. i tried entering the values of the coordinates directly for google maps to display. it works then. however, it just seems to be an issue when using the objects UserCoords.lat and UserCoords.lng in the google.maps.latlng(UserCoords.lat,UserCoords.lng) object... what data types does the latlng take and how do i transfer it? Link to comment Share on other sites More sharing options...
mbpowner Posted October 12, 2017 Author Share Posted October 12, 2017 sorry about this.. managed to resolve this too by putting it all in the method.. not sure why it wasn't accessible to the variables outside though Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now