Hide geolocation of embedded map from user - javascript

I want to embed a googlemap in a page but I don't want the user to be able to determine the geolocation by inspecting the code.
I've tried using the Javascript API to insert the map and loading in the Geolocation in a separate JS file which has been minified but the lon-lat are still easily identified.
Any tips on how I might go about doing this?
p.s. I know it sounds like a weird thing to want to do! It's for a puzzle and I don't want people to be able to cheat :-)

How about calling a service to get the geolocations? You could iterate over the results add the markers (I do it with google.maps.event.addListener to include a tooltip as well).
A user would have to inspect the result from the service.
If you want, you can use unique identifiers for your service calls, that are only valid once. A disadvantage would be that page refresh aren't possible anymore, because you would call the service with the same parameters again.

Related

GA Basics – Best practices for page view tracking in dynamic PHP based sites

Sorry for the basic question, but I've been reading lots on this and haven't been able to piece together a solution (as a rookie developer) so thought maybe asking would be helpful to me and others in the same boat.
I'm attempting to install GA (gtag) on a PHP site. The initialisation code works fine, Google Tag Assistant is happy, but the site functions similar to a single page application whereby the content is all loaded in dynamically via js into a DIV (little floating overlays).
I've read that creating a separate analyticstracking.php file is a best practice for the inclusion of your tracking code on pages (using include_once), but doing this on the dynamically loaded php files seems to throw up an error within tag manager – "Same web property ID is tracked twice."
My assumption was that this was happening because the page name didn't change, which would be logical, but if true, how and where does one change the page name?
Is it best to do this as an event when the nav item loading content is clicked, or is it best to somehow include tracking data in the PHP files for loaded content (and how)? If the latter, is is possible to pass the page name to the included analyticstracking.php call on load?
Or perhaps I doing this all wrong and should I be using Google Tag Manager?
Thanks in advance,
Joel
Best solution for your situation i guess will be something called "virtual pageview". Google Analytics documentation describes it here: https://developers.google.com/analytics/devguides/collection/gtagjs/single-page-applications
In shortcut:
Include Google Analytics (or GTag) code only once, for example in head.
Every additional content loading (which is key for you and want to treat as a new pageview) should send JS code with new "virtual" pageview to GA with datas seted by you (like new pageview title, new pageview url etc.).
Forget about sending events in this case as a "core". Of course you can also track events with nav clicks but first implement virtual pageviews.

Workflow with Google Maps API

I just need to know where to start. I'm developing an app with Meteor framework, where I need to have let's say a custom marker, which I get from user's input, so this marker shows up in a place where user stands through geolocation. I need to get this input when a user taps a button like "i'm here", so what's the best way to make it so? Some JS on button? Any examples would be appreciate, thanks.
Use dburles:google-maps . The documentation is well written and easy to use. Use GoogleMaps.maps.exampleMap.instance to set the current location on the button click.Grab the users location using either HTML5's location ability or a cordova plugin that provides the same functionality, depending on the app's user base. You could also completely eliminate the need of the button and initialize the map with the users location. See the above package documentation.

Preview and edit external website

I have a difficult one
I am trying to show an external website within my page (currently using an iframe)
The trick is I want to be able to edit the site
e.g. I really want to show a preview of another website that I can modify.
Not sure if there is any tools out there, was thinking of using a jquery request to create a page within my domain that I can edit?
Any advice?
If that would be possible from within the browser, that would be a bug.
The way you should do it, is creating some sort of a proxy on your own domain/server, and fetch the site through there. Then you're allowed to access the iframe and edit whatever you like.
Of course, the site won't run like it normally would, since it can't use its own cookies, AJAX calls, etc.
I think this js library could inspire you something!
easyXDM

iphone, uiwebview with JS (google maps API)

two question for you:
reading google documentation i've make an html with the JS for make a google maps api call.
I've put this file in my project, and in a TABView i read and render this file in a uiwebview.
Works great but every time i start my app and go to this view i got this message: "appleweb://someID want to use your current location".
Is my fault or is normal? why my authrization is not saved in position auth?
Second: if i must make some other request on my map and passing new data or refreshing existent data is better that i do this via javascript or there's some option in cocoa to refresh my view?
It is surely not your FAULT, and yes it is normal. user location authorization SHOULD NOT be saved because the next time user launches his app he wont be knowing that his current location is being used (just in case he wants to avoid that for whatever reason).
I dont know the answer to you second question but just a suggestion: why don't you use MapKit API provided by apple instead of going with html and js for google maps? It is pretty easy to use and theres enough documentation and sample codes available on ADC.

Embedding web controls across sites - using IFrames/Javascript

I'm just looking for clarification on this.
Say I have a small web form, a 'widget' if you will, that gets data, does some client side verification on it or other AJAX-y nonsense, and on clicking a button would direct to another page.
If I wanted this to be an 'embeddable' component, so other people could stick this on their sites, am I limited to basically encapsulating it within an iframe?
And are there any limitations on what I can and can't do in that iframe?
For example, the button that would take you to another page - this would load the content in the iframe? So it would need to exist outwith the iframe?
And finally, if the button the user clicked were to take them to an https page to verify credit-card details, are there any specific security no-nos that would stop this happening?
EDIT: For an example of what I'm on about, think about embedding either googlemaps or multimap on a page.
EDIT EDIT: Okay, I think I get it.
There are Two ways.
One - embed in an IFrame, but this is limited.
Two - create a Javascript API, and ask the consumer to link to this. But this is a lot more complex for both the consumer and the creator.
Have I got that right?
Thanks
Duncan
There's plus points for both methods. I for one, wouldn't use another person's Javascript on my page unless I was absolutely certain I could trust the source. It's not hard to make a malicious script that submits the values of all input boxes on a page. If you don't need access to the contents of the page, then using an iframe would be the best option.
Buttons and links can be "told" to navigate the top or parent frame using the target attribute, like so:
This is a link
<form action="http://some.url/with/a/page" target="_parent"><button type="submit">This is a button</button></form>
In this situation, since you're navigating away from the hosting page, the same-origin-policy wouldn't apply.
In similar situations, widgets are generally iframes placed on your page. iGoogle and Windows Live Gadgets (to my knowlege) are hosted in iframes, and for very good reason - security.
If you are using AJAX I assume you have a server written in C# or Java or some OO language.
It doesn't really matter what language only the syntax will vary.
Either way I would advise against the iFrame methods.
It will open up way way too many holes or problems like Http with Https (or vice-versa) in an iFrame will show a mixed content warning.
So what do you do?
Do a server-side call to the remote site
Parse the response appropriately on the server
Return via AJAX what you need
Display returned content to the user
You know how to do the AJAX just add a server-side call to the remote site.
Java:
URL url = new URL("http://www.WEBSITE.com");
URLConnection conn = url.openConnection();
or
C#:
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://www.WEBSITE.com");
WebResponse res = req.GetResponse();
I think you want to get away from using inline frames if possible. Although they are sometimes useful, they can cause issues with navigation and bookmarking. Generally, if you can do it some other way than an iframe, that is the better method.
Given that you make an AJAX reference, a Javascript pointer would probably be the best bet i.e. embed what you need to do in script tags. Note that this is how Google embed things such as Google Analytics and Google Ads. It also has the benefit of also being pullable from a url hosted by you, thus you can update the code and 'voila' it is active in all the web pages that use this. (Google usually use version numbers as well so they don't switch everyone when they make changes).
Re the credit card scenario, Javascript is bound by the 'same origin policy'. For a clarification, see http://en.wikipedia.org/wiki/Same_origin_policy
Added: Google Maps works in the same way and with some caveats such as a user/site key that explicitly identify who is using the code.
Look into using something like jQuery, create a "plugin" for your component, just one way, and just a thought but if you want to share the component with other folks to use this is one of the things that can be done.

Categories

Resources