Google Maps Loading Async Issues - google-maps

I'm trying to get Google Maps API v3 to work on my site and I'm running into 2 problems.
I'm using yepnope to load the API script asynchronously, and I get a "Load denied by X-Frame-Options" error in my console. It says http://maps.googleapis.com/maps/api/js?sensor=false&callback=init_google_maps&ver=3.0 does not permit cross-origin framing. This is odd to me because I'm not loading anything in a frame of any kind. Note that the map still loads, but the error in the console concerns me.
The map controls aren't displaying correctly. I don't think that this is related to the first issue because I get this even when I load the API the traditional way (synchronously), but it might be related in some way.
I'm not sure if it matters, but I'm running this on my "localhost" testing server. Any ideas on what could be causing these issues?
Update:
As discussed below, the X-Frame issue only occurs when I load the API via yepnope. I can't understand why using yepnope to inject a script tag causes the error and using a simpler js function doesn't though. My main concern, however, is the display of the map. I tested the map on a more stripped down page on my local server, and it displayed correctly. So, my current assumption is that I have a style (or script?) declared somewhere on the page that's interfering with Google maps.
Update 2:
Ok, the display issue if finally sorted out. I went through my main stylesheet and commented out portions until I had found the culprit. In order to make my images responsive in my fluid layout, I had declared img { max-width: 100%; }. Apparently, Google Maps don't like this. Once I overrode that style for the map container, everything displayed normally. The X-Frame issue still confounds me however.

Regarding the first problem, if you want to load the Maps API asynchronously, I would suggest using the technique described in the API documentation directly (a simple dynamically inserted <script> element) instead of yepnope. It should work fine that way.
On the second problem, running on localhost is no problem; that's a normal way to test a Maps API page. (I assume you mean using a local web server and loading your page in the browser from a localhost:// URL, not a file:// URL.)
Some symptoms like this can be caused by the map container element not being properly sized when the map is first created. In particular, trying to use height:100% can be problematic. But it's hard to guess without seeing a running example. Can you post the code to a web page somewhere? Maybe even in a JSFiddle if nothing else.

Related

How can I make requests to non chrome:// sites from the newtab page?

I got an injection to work through using the chrome://flags/#extensions-on-chrome-urls flag and modified the dom of the page and added a sidebar. Now, my goal is to access an API from another site to get certain data to populate the sidebar with. I very quickly found out that any attempt to access non chrome:// sites from the newtab page causes it to just not work. It just always says ERR_FAILED. Is there another flag or something similar I can do to allow me to make requests that aren't from the chrome://? Also, this is an extension intended for personal use only, so modifying anything about my browser to get this to work would be fine.

How to find the HTTP request from google chrome inspect element?

Forgive me if I don't use the proper terminology. I have a webpage that I'm trying to scrape information from. The problem is that when I view the page source the data I want to scrape is not there. I've encountered this problem before where the main http request triggers other requests and so the information I'm looking for is actually somewhere else which I find using Google chromes inspect - Network feature. I manually search the various documents and xhr files so the one that has the correct information. This is sometimes long and tedious. I can also use google chromes inspect feature to inspect the element that contains the information I want and that brings up the correct source code but it I can't seem to figure out where or how I can use that to quickly find the corresponding HTTP headers.
Restated in a short - can I use the inspect element feature of google chrome and then ask it to show me the corresponding network event (HTTP request) that produced that code?
I'll add the case study I'm working on.
http://www.flashscore.com/tennis/atp-singles/acapulco/results/
shows the different matches that took place at a tennis tournament. I'm trying to scrape the the match hrefs but if you view source of the page you'll see they're not there.
Thanks
Restated in a short - can I use the inspect element feature of google chrome and then ask it to show me the corresponding network event (HTTP request) that produced that code?
No. This isn't something that the browser keeps track of.
In most situations, the HTTP response will pass through a good deal of Javascript code before being eventually turned into elements on the page. Tracing which HTTP response was "responsible" for a given element would involve a great deal of data flow analysis, and is impractical for a browser to do.
One way:
open firefox, install LiveHttpHeaders, then run it, and you will see the expected HEADERS.
There's the same addon for google chrome, but not tested.

Using Instagram API for simple web page

So I am working on a fairly simple project, basically a web page that should list the captions from a certain instagram account. It's all designed, it just needs to be lit up with the content. Have a look at http://evanshellborn.com/speechofthebeets/.
I found that you can see a json file containing all the necessary data at instagram.com/{username}/media. So in my case, https://www.instagram.com/beets_are_life/media/. So before I put that page actually online, I was on my local machine, and I did a JSON call to that page and it worked perfectly. So I built it all out and my web page loaded the captions just like I wanted it to.
Then I went to put it online, (http://evanshellborn.com/speechofthebeets), but it doesn't work. Have a look at the script at the bottom of it, on my localhost that code works and the captions get loaded. But on the live page, I get an access not allowed error in the console. So I think Instagram doesn't allow this sort of direct access anymore, you have to go through their API.
Now I've tried looking at the API but it seems rather confusing. Basically what I'm asking for is a different JSON url that would give me the same result as https://www.instagram.com/beets_are_life/media/, but that would work from the live page.
I think https://api.instagram.com/v1/users/{user-id}/?access_token=ACCESS-TOKEN would work, just replacing {user-id} with the appropraite user_id. But where do I get an access token?
From reading https://www.instagram.com/developer/authentication/, it looks like you get one when a user puts in their user credentials. But I don't want to have anyone log in, I just want a simple web page.
Hopefully that made sense. How can I do what I want?
Looks like the API url https://www.instagram.com/beets_are_life/media/ does not support jsonp (no callback support), so u cannot use javascript (client side) for making API request, it will fail because of Access-Control-Allow-Origin error on browser side, you have make this API call on server side as proxy.
I guess https://www.instagram.com/<USER_NAME>/media/ is not a publicly documented API, thats the reason it is not supporting jsonp, Instagram uses it for their website and since it is same-origin it will work for them on client-side
This link will help you embeding the instagram on a simple html webpage.
There is a button on the bottom of the post on instagram.when you click on the link a menu pops up. then click on embed
now a box pops up
just copy paste the html and you are done.
it will fetch the post for you

Error When Loading Images on Local Host Test Server

I have a peculiar problem that I just can't seem to find an explanation.
I'm working on an AngularJS site for our family and am integrating data from various web services. Currently I am working on the photos section which will integrate in photos from our Flickr account.
I have a main page which lists the various photo sets and displays the set's primary photo along with the title. (Note: I'm using the Flickr 'extras' parameter to return the primary photo's URL in the API calls.)
<div data-ng-repeat="p in vm.photoSets">
<a ng-href="#/photos/{{p.id}}">
<img ng-src="{{p.primary_photo_extras.url_s}}"></img>
</a>
<h4>{{p.title._content}}</h4>
</div>
When clicking on the photo, the routing will display a page with a list of all the photos from that set, showing the image and the title.
<div data-ng-repeat="p in vm.photoSetData.photo">
<a ng-href="#/photos/{{vm.photoSetId}}/{{p.id}}"
<img ng-src="{{p.url_s}}"></img>
</a>
<h4>{{p.title}}</h4>
</div>
Now, here's where the problem is occuring. When I upload the code to my public website on my hosting provider, everything works just fine. Both pages display their respective photos. However, when I attempt to run the site on my local system, either in MAMP or NodeJS (using http-server), the second page gives me an error for each image:
Error: [$interpolate:interr] Can't interpolate: {{p.url_s}}
Error: [$sce:insecurl] Blocked loading resource from url not allowed by $sceDelegate policy. URL: https://farm1.staticflickr.com/37/82749767_e82ff60ce3_m.jpg
http://errors.angularjs.org/1.2.9/$sce/insecurl?p0=https%3A%2F%2Ffarm1.staticflickr.com%2F37%2F82749767_e82ff60ce3_m.jpg
http://errors.angularjs.org/1.2.9/$interpolate/interr?p0=%7B%7Bp.url_s%7D%7D&p1=Error%3A%20%5B%24sce%3Ainsecurl%5D%20Blocked%20loading%20resource%20from%20url%20not%20allowed%20by%20%24sceDelegate%20policy.%20%20URL%3A%20https%3A%2F%2Ffarm1.staticflickr.com%2F37%2F82749767_e82ff60ce3_m.jpg%0Ahttp%3A%2F%2Ferrors.angularjs.org%2F1.2.9%2F%24sce%2Finsecurl%3Fp0%3Dhttps%253A%252F%252Ffarm1.staticflickr.com%252F37%252F82749767_e82ff60ce3_m.jpg
minErr/<#http://localhost/scripts/angular.js:78
$interpolate/fn#http://localhost/scripts/angular.js:8254
$RootScopeProvider/this.$get</Scope.prototype.$digest#http://localhost/scripts/angular.js:11800
$RootScopeProvider/this.$get</Scope.prototype.$apply#http://localhost/scripts/angular.js:12061
done#http://localhost/scripts/angular.js:7843
completeRequest#http://localhost/scripts/angular.js:8026
createHttpBackend/</jsonpDone<#http://localhost/scripts/angular.js:7942
jsonpReq/doneWrapper#http://localhost/scripts/angular.js:8039
jsonpReq/script.onerror#http://localhost/scripts/angular.js:8053
The API call to Flickr is successful and returns the correct data. In fact, the image title does display! I've tested it with Firefox, Safari and Chrome...all three browsers fail.
I cannot find any explanation as to why it would work remotely but fail locally. Also, the images show up on the first page, but not on the second, even though one of the images on the second page is the same image URL as on the first page. Even going directly to the second page, bypassing the first page, still fails.
Any ideas on how to fix this? It would be nice to test locally without having to upload to the server each time I make a change.
Update:
I have shut off the $sce security to see if that was causing the issue. Although it resulted in turning the error off, the files still don't load on the local test server. I have used the developer tools' network monitor and it doesn't even show an attempt to retrieve the files. AngularJS appears to shut down the retrieval, although the correct path shows up in the DOM.
Based on the symptoms, it just seemed that something was wrong with the second page. After looking through the DOM, I noticed something strange about the a and img tags. It seemed that the entire img tag was embedded into the a tag.
So, I went back to the html markup and noticed the missing closing bracket. The entire issue was caused by the a tag not being properly closed.
I'm still trying to understand the error that AngularJS was throwing and how it would relate to the incorrect markup.

How do I open the device's default navigation app through a URL?

Good Morning, everyone
I'm dealing with a problem in an application developed using Cordova, for android. In a certain page of the application (everything is constructed using pure HTML and Javascript), I need to open a route when the user clicks a link. After many hours of research on the internet, I could find some options, but none of them dealed with it.
Here I give you what I found and tried so far. Please assume that the coordinates represent a viable location for the route..
Using the geo: schema
Example: Route
Problem: This was the one that nearly solve it. The problem here is that geo: opens the map application showing the position given in the coordinates. All fine until there, but there is no option using this schema to open with a route, as I could figure out reading the specification.
Using maps.google.com in the link domain. Example:
When trying this using the device's browser, I could open the navigation app. But using it inside a hybrid application as the on I'm building just redirects it to Google Maps site, using it's mobile version. But it happens inside my application, what now seems logical to me but really freaked me out, since it's not possible to control that. (Unfortunally an iframe is not a viable option because of the standarts that we addopt in the project.
Using a target=blank on that link didn't changed nothing.
My last try was using the google.navigation schema.
Example: <a href="google.navigation:q=45.6,32.8" target="_blank">
Again, if I test it in a common device browser everything works just fine but when I try it on my app it crashes, saying that "google.navitation is not a supported protocol."
UPDATE
I've also tried the option present here, with the following format:
Route to here
The application also crashes and I'm alerted that the comgooglemaps:// schema is not supported.
I could findthese 4 options, since everyone that had similar needs could find a solution using them. Is there any other way to do that? I really appretiate any help from you, if possible, with some documentation/specification/whatever link about that.
Thank you for your attention.