Display the Google Maps Javascript API usage statistics on a custom website - javascript

I'm currently using the Google Maps Javascript API for displaying multiple Google Maps on a website. Since the usage is limited for non-paying users, I am trying to keep the usage as low as possible, but I would love to have a way to monitor those usage stats in a semi-realtime way.
I know that you can lookup these usage statistics in the Google Development Center, for different timespans, but I was wondering if it's possible to query those usage statistics in some sort of way for displaying them on a custom webpage?
I've already tried to find some topics here on StackOverflow around this subject, but the only one I've found that comes near to my question is this one from 2013:
Is it possible to display the statistics from the Google Developer Console on a website?
In that topic the correct answer was that it wasn't possible at that moment.
Is this still not possible at this moment or does anybody know a way to get those usage statistics out of the Development Center?

Unfortunately you can not see the statics on a custom web page.

It's not possible to get the usage information out of the Developers Console, but you could wire up the Maps JavaScript API to report back to your own analytics services which is easier to embed.
As an example, using Google Analytics, every time your code runs new google.maps.Map(.. you could run ga('send', 'event', 'map', load'); reporting that a map was loaded. The numbers might vary slightly since some users block analytics but I would expect them to line up closely.

Related

Reverse geocoding Google API without map javascript

I'm working on a function that takes from the javascript geolocation functionality the latitude and longitude of a certain place, puts those values inside a https://maps.googleapis.com/maps/api/geocode url and given a country and a specific time, redirects to a site or to another.
My question is, and i´ve really done tons of research. Can I do that?
This is why i´m asking.
In the ToS https://developers.google.com/maps/terms#section_10_4 says:
" No use of Content without a Google map. Unless the Maps APIs Documentation expressly permits you to do so, you will not use the Content in a Maps API Implementation without a corresponding Google map. For example, you may display Street View imagery without a corresponding Google map because the Maps APIs Documentation expressly permits this use. "
Also, am I to inform the user that i´m using such service? Because that it´s also amongst their ToS.
Thank u so much, I´m quite lost regarding that, because I don´t know if the page might get shut down if i use my function and dont put a map on the page nor if i dont alert of the use to the users.

Using Google Maps offline (Js Api)

I'm trying to make an NodeJs App in which, on web page I'm using Maps, For some reasons I've chosen Google Maps and I want to stick to it. My question is, Is there anyway where I can either store or cache map tiles offline and later on use it as needed [Note: Not looking for any hack or Illegal way for it, I already know there are many such ways].
I tried and saw many options like GEE (Google Earth Enterprise) portable but I guess they are shutting it down very soon i.e by 2017.
Basically what I'm trying here is to minimize the data usage on rendering map tiles, so alternatively, if there ain't a way to make google map work offline any suggestion or advice for minimizing data usage is appreciated.
The offline access via Maps JavaScript API is not available at the moment. There is a feature request in the public issue tracker:
https://issuetracker.google.com/issues/35827808
Please star this feature request to express your interest and receive further updates from Google.
1.Use Localstorage instead it might help but will be used in google chrome.
2.Check this url it might help How to cache Google map tiles for offline usage?

Several questions about Google Maps Engine. Which version of engine? API?

I have a customer who wants a site with a map included. The requirements are as follows:
The map needs to be easily edited by the customer(which is why i ended up with Google maps).
The map needs to have markers with info about stores(which is why i think i need maps engine business, since its possibly money involved).
The site I'm making needs to have a search field, which should navigate to the correct location when a option (lets say New York) is selected(which i why i probably need to use the API).
Am i correct in the consumption's above? I'm very confused by all the developer guides, and different map options(lite, pro, engine, not engine etc). I keep opening new links, and they tell different things.
If i make my map public(which i can), will i still have to use OAuth 2.0? The guides i found said i didn't have to, but i still cant get info from the API. The response says i need to add the bearer.
More questions:
- Why can't i add markers when i use the "standard" maps engine, but only the lite one? I'm guessing the lite version wont be suffice for my project. The icons for adding marker is grey, and it gives me warning icon when hovering with my mouse.
- If i navigate to my map with the lite version i can't see my map-id in the url(this might be because it cant be used for API?). It seems i can get my map-id from the "real" maps engine.
Google has three products in this field: Maps Engine Lite, Maps Engine Pro, and just plain Maps Engine. This page explains the differences, but it sounds like you would be best off with Maps Engine Pro.
Both Lite and Pro let you embed your map easily into another webpage. No programming, OAuth etc needed, just copy and paste the pregenerated code.
Pro lets you add up to 2,000 points per layer onto a map, with full custom styling. (Lite is limited to 100 per layer and a set of default icons.)
Lite is free, but Pro costs only US$5/month, so it's not going to break the bank.
The only issue is going to be that search box. Maps Engine Lite & Pro maps in the default standalone viewer have a search box that does what you want, but the embedded iframe version only has a list of points. Might be good enough if you don't have too many?

Using Google Analytics without importing the snippet

In my current job I have to import an analytics framework into our clients pages (we're a 3rd party also, our services are provided by including our tag in the client's pages) for counting basic metrics such as: Visitors,Visits,Views,Avg. Visit duration,Bounce Rate,Pages/Visit .
I've looked at several opensource solution such as piwik etc.. but as we handle allot of traffic this will come at a pretty hefty price, so obviously GA seems like the most reasonable solution for us. the problem is that the bulk of my clients already have GA on their pages and everybody has a different version of it (analytics.js,ga.js,dc.js etc..) where each version has a different method of working with multiple trackers on page and some don't support that all together. so using a pixel reporting technique seems like the safest method to use here but .. I can't find any documentation on google or anywhere else for that matter explaining what functionality I will loose when using this approach.
The API documentation does a decent job of showing me how to do it myself and there's also nojsstats (which i prefer not to use) but has anyone had any experience with this kind of a scenario and can eloborate on what functionality will be lost as a result of this approach? or has found a different solution for this kind of problem?
Thanks in advance,
Amnon
You can look into the parameter reference for the measurement protocol - that's what you can get, provided you pass all the parameters (so everything that's not in there you lose, most notably all Geo information which will be set to the location of your server).
The biggest challenge would be that you'd have to maintain a session id in your respective clients applications, else you'll only register single page visits with 100% bounce rate (since Google will not know which visits belong to the same user). That seems a lot more cumbersome than additional javascript trackers.
However since they already have Google Analytics you do not need to implement any tracker at all, you can query the existing accounts via a serverside language of your choice (or via Google Apps Script). Which is actually what the documentation you've linked to describes (Core reporting API is not about collecting data, but about querying existing data).

OpenLayers vs Google Maps? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have used Google Maps a couple of times, but what wondering about OpenLayers.
Before starting any kind of coding, here are a couple of questions that come to my mind,
Why would I use OpenLayers instead of Google Maps?
Except for its OSS licence, anyway
Did you encounter any situation in which you'd recommend absolutly not using OpenLayers?
I did a search about "OpenLayers" on Stack Overflow; there are not many answers. Does it mean this solution is not used much? Could it be a problem for long-term viability of the project?
For those of you who have already used OpenLayers: are there any common pitfalls / problems I may encounter?
What about using a JavaScript Framework with it? I've seen it's using Prototype, and I know Prototype, so that would be OK. But what about using something else like MooTools? (Which is not compatible with Prototype, BTW)
Are there any kind of speed and performance related problems? I need my application to be responsive and can't wait hours to get a map displayed.
Are there maps available for many places, or are there lots of those missing?
That is, I'm in France, and need my application to work at least for big cities... Will that be OK?
if not, is it easy to find layers and visualisations for OpenLayers and integrate them?
Is there any kind of API to display roads?
For instance, to show roads that are one-way only.
If yes, how can I do that? Do I have to have some kind of file containing those roads information, and, then, display them on the map by myself?
Do you know any good tutorial to OpenLayers?
I have not tried it yet, those are just out of the blue questions...
These are a really great questions! I'm a professional OpenLayers developer and fan, so I'll address your questions from that perspective.
Why would I use OpenLayers instead of Google Maps?
Flexiblity: You are not tied to any particular map provider or technology. You can change anytime and not have to rewrite your entire code. Google, Yahoo, Microsoft, WMS, ArcGIS Server, MapServer, etc. are all supported out of the box.
Vector Support: Better support for points, polylines, and polygons.
Control: You have the ability to add any new features that you may need. I've personally written three plugins for OpenLayers, two of which are or will be part of the source.
Debugging: Much easier to debug when you can step through the source code!
I would not worry at all about the long-term viability of the project. It is the premier open source client-side mapping library.
Are there any common pitfalls / problems I may encounter?
The biggest pitfall I've run into is working with the Web Mercator (Google) projection. It can be a pain to display vector data that is in a common and real projection like WGS 84 into an OpenLayers map using Google, Yahoo, and Microsoft base maps. The examples are your friend.
JavaScript Framework Compatibility
I use the jQuery framework for all of my work, and the only problem I've had is referencing jQuery after OpenLayers. Other than that, it's been smooth sailing.
Performance is great! The only issues will be with your map server or adding too many vectors to your map.
Are there maps available for many places?
Like I said, you can use basemaps from just about any source for anywhere in the world.
Is there any kind of API to display roads?
I'd check out CloudMade! The have converted the OpenStreetMap project into a map tile service and allow custom styling. I believe that you can style one-way streets (per your example) a particular way. The CloudMade Developer Zone.
Do you know any good tutorial to OpenLayers?
I don't know any tutorials, but there are a ton of examples in OpenLayers Examples
I hope this is useful. And I'm around Stack Overflow if you have any questions!
It's not necessarily a question of OpenLayers OR Google Maps. You can after all use Google Maps for your map background in OpenLayers. Some more specific answers:
Why OpenLayers?
OpenLayers can combine maps from different sources (Google Maps background, WMS overlays, vector data from KML or GML files or WFS etc)
You can style OpenLayers much more thanyou can Google Maps
Open source, you can check the source code when debugging
If you need high precision in the maps, use OpenLayers with a suitable map server backend rather than Google Maps to get a better map projection (Google Maps assumes that the earth is a perfect sphere)
Pitfalls
If you want to use vector (WFS) data from another server you need a proxy, due to cross site scripting limitations
Performance
Depends mainly on the speed of the map backend
Displaying many vector features (limit is browser dependent, but say > 200 on one view) takes time, but that is more a browser thing than a problem with OpenLayers
JavaScript frameworks
Have a look at GeoExt, which is ExtJS + OpenLayers, for example
Available maps
OpenLayers doesn't come with a map backend. You can use Google Maps, Yahoo Maps, MS Virtual Earth etc, or any WMS and WFS service tou have access to
I haven't seen much of a presence from OpenLayers users on SO but they're out there. The OpenLayers mailing lists are pretty active (I'm on Users and Dev and see anywhere from 50-100 emails a day discussing various things. You can search the lists from those links too.).
I can't answer all your questions but one thing I'll put out there is that OpenLayers and google maps aren't mutually exclusive. OpenLayers is a javascript library and you can use it to interact with google maps. Check out this example: OpenLayers using google maps. And here's the main OpenLayers examples page.
It really depends on what you want to use the map for. To simply plot points on a map, Google Maps will be fine. The map layers for Google Maps are also quite detailed. OpenLayers on the other hand offers far more functionality and is very extensible.
OpenLayers have lots of examples to get you started.
As for maps, OpenLayers is only an API so you need to supply it will map layers. The Google Maps API will be limited to the map layers supplied by google. With OpenLayer you can display pretty much any publicly available map service (WMS, WFS, TMS, WMS-C). A very good example is openstreetmap.org - (global streets map collected by the community). OSM can be added to openlayers as a TMS layer. Check out this example for instructions.
One point that hasn't been fully made here is that using OpenLayers avoids various restrictions Google places on the terms of service for its map APIs, including:
You can't legally use a Google map solely in a section of your site that requires payment to access, or for a private site that the public can't sign up for (e.g. a corporate intranet). (IANAL, but see Terms of Service, 9.1 and the FAQ)
You can't legally (or practically) use the Google API for offline applications (i.e. where the tiles are served from your own machine). Even if there weren't legal restrictions, Google makes this technically very difficult, while OpenLayers makes it easy.
Google reserves the right to shut down access to the API if you're showing a map with content it finds objectionable. The example given in the FAQ is a map of illegal drugs, which gives a good sense of the gray areas this restriction might cover.
See this FAQ and the Terms of Service for more details.
All that said, as a long-time Google Maps developer who recently started using OpenLayers, I feel that Google Maps has better documentation, a larger user community, and a clearer and more stable API than OpenLayers. So you have to make a trade-off somewhere.
I agree with all answers, but there is one very important point that nobody mentions.
OpenLayers and Google Maps have different targets.
OpenLayer is an excellent framework to display geodata, but Google Maps is a pool of services that include a framework to display geodata among other services.
So, Google Maps expose a lot services and features that OpenLayes do not have.
Some examples of Google Maps features and services are region localization, sensor detection (for device with GPS) and user localization, geocoding and reverse geocoding, street view, etc.
Some clients may refuse, or have strong reservations, about using Google Maps. They may have valid concerns that Google may introduce advertising or change the API without notice.
However Google Maps does have the benefit of integrating with other Google services (placemarks, adding photos, geocoding services).
As its the web you can always combine many different mapping services and APIs.
I have used both APIs. I make a software for corporations and this software requires mapping but not all clients have a GoogleMaps license, so I need to support both types of maps.
I have made a common API for abstracting the differences between them and let me tell you, some stuff is easier to do in one than the other. Like limiting the bounds of where you can pan the map to, it is a lot easier to do in OpenLayers, but heatmaps are easier to use on GoogleMaps (it is officially supported by google, unlike the available OpenLayers plugins).
OpenLayers support offline maps. Some of my users are in private
intranets without internet connection.
GoogleMaps has two absolutely must have plugins, MarkCluster
and Spiderfier that makes possible visualizing a huge numbers
of markers.
GoogleMaps InfoWindows are easier to use and have better
usability than the OpenLayers.Popups. These are the little windows
that can open when you click in a marker. Googlemaps InfoWindows are
also a lot more pretty by default, you have to do some CSS wizardry
with the Popups.
GoogleMaps has streetview which is useful sometimes.
GoogleMaps has more features that you might need. Although many
features are present in OpenLayers too, but not officially
supported.
Usually in the end you should go with OpenLayers because of the reduced headache you might get from licensing and bandwith usage from googlemaps. Both handle basic mapping (ie, displaying markers on top of a map) very well. Unless you can find a specific feature you need from one that is not present on the other you should go for OpenLayers.
See this for more information about googlemaps billing and when you can use it for free.
Also GoogleMaps has its basic geolocation type as 'LatLng' and Openlayers use 'LonLat' which drives me freaking nuts because I keep mistaking the order of the parameters in function calls.
In addition to those who mentioned speed problems, I would like to add that IE's VML renderer can get really slow with a vector layer with many features. One user mentioned about 200. That's about exactly what I can add before IE slows down considerable to the point of freezing. If you add features that are text labels, you can add half less, probably because internally each text label consists of two VML elements.
In Google you may create a custom GOverlay whose content is a "div", which gets rendered without problems in IE.
A couple of things I would add, from two perspectives: client usage and data derving.
Client usage:
What are you clients used to using currently? Change can be difficult.
How much functionality do you really need? OpenLayers has quite a bit, but if you are not using it...
Data serving:
Are you serving KML data? If so, both OpenLayers and Google Maps will work with it, and you are probably going to have to decide based upon client usage.
Are you serving other types of data services? (WMS, WFS, CSV, etc.) If so, then OpenLayers very likely has examples and support for it.
OL has a large fanbase and is perhaps the most used Opensource geothing used in the world.
You dont see that many threads and posts about it in this cyberplace because people here tend to discuss other kind of techs, like JSF and Mobile (non geo), not because OL is like struts.
However Ol has some drawbacks, mainly that it's so low level that you have to write lots of code to do common ops. That can work in the good way too, because as a developer a: you have all the code upfront and b: tweaking and customizing is very easy.
There are more sophisticated free geotools, but all they do is call openlayers and abstract some of the more boring chores.
So use it confidently. It's mature, robust and it's not going to die in the foreseable future. However if you want to speed up your developing process you should try the other tools that mount in top of it.
have a nice day

Categories

Resources