Handling large amount marker - google-maps

In this case, i want to display log route of an a car. I have create polyline (flightPath) to display the route. And because I also want to know speed of car in certain position (coordinate), I also have create marker on the route.
This is my code (question) before Tooltip on Polyline (Route) Hover. The problem is when the numbers of marker is very large (bulk). The route will displayed slowly. Mr geocodezip has give me a reference on that thread (Too Many Markers!).
Grid-based Clustering
Distance-based Clustering
Viewport Marker Management
Flash
Fusion Tables
MarkerClusterer
MarkerManager
But I confuse what solution is the best one for this case. I think Distance-based Clustering or maybe MarkerManager is suitable for this case, but I am doubt maybe another is better. And I want to ask about that, what is the best way to handle this. MarkerClusterer? Fusion Tables? or maybe another library? Thank you.

Related

How do I obtain the coordinates along GMaps directions?

I want to create an online map for a hiking trail, and I have been using my smartphone to collect coordinates from it.
I have many questions regarding what's good practice when it comes to making such tracks, but for starters: it would look much neater if I could edit the readings so that they are right on top any roads in Google Maps. How can I achieve this?
EDIT: I want to find the coordinates that will make a track along a road look exactly as if I'm using snapping/directions even when I'm not.
I've tried tools such as QLandkarte GT and Viking, and with the latter I was able to manually remove excess coordinates and move the remaining ones so that they're exactly on top of roads (inside Viking, using OpenStreetMap). However when I load the edited .kml-file in Google Maps, the roads seem to be in slightly different places and the result is hardly better than before editing.
I tried using the hack that exports GMaps directions as .gpx, thinking I could insert Google's own coordinates along the roads. But the exported file only had coordinates at the turning points with straight lines between these.
QLandkarte GT supposedly has a snap-to-road feature (see answer in link), but I haven't found it and I also don't know how to obtain a vector map of the area.
Then there's Google Earth which people seem to use for this, but again I can't find any track editing features (in the free version).
In short:
How do I edit my existing tracks so that they match roads in GMaps...
OR
How can I obtain new tracks representing roads in GMaps...
...so that the resulting track is as smooth as Google's own directions or other professional GPS-data, when displayed in GMaps?
It seems like it's possible to get these coordinates from Google Maps after all, exporting the directions polyline. I'm not sure how, it seems to involve adding the parameter output=dragdir to the link.
Anyway there's a tool called GPS Visualizer that can create a .kml-file with the wanted coordinates.
Edit: Will accept my own answer as long as it's the only one, but I would still like to know more.

Google Maps - Grid based clustering

on this page https://developers.google.com/maps/articles/toomanymarkers
it says how this is the easiest clustering posible, but I can't find any client side solution for this. Does anyone know for free open source, client side solution of grid based clustering for google maps markers ? i don't want MarkerClusterer.
I didn't find it, so i went and start coding my own solution. The first obvious request is that it has to be fast for up to at least 1000 markers loaded on map. Every zoom in out, move and soo on, will repeat procedure/function of clustering. Grid blocks are customizable, default value is 50*50 pixels.
Image below is showing what should the result look like.
I'm having problem with algoritem, now all I can think of to achive this is to itterate through all markers for each grid and ask if it is inside bounderies and then increase array of grid ++. This obviusly can't be done that way. There should be some hash or something that just one itteration through all markers would be needed and I would know in which grid specific marker belongs to.
I hope someone will give me a hint for algoritem I'm after. Thank you !
Seems like geohash is the answer to your problem, you even allude to that solution in your question. It's explained well here:
http://blog.trifork.com/2013/08/01/server-side-clustering-of-geo-points-on-a-map-using-elasticsearch/
I am actually exploring developing a similar clustering algo for Google Maps API v3. I'll post more if I actually get anywhere with it.
You can use a geohash or a space filling curve to reduce the dimension and reorder and hash a marker. On the server side you can use a point and a spatial index data stucture but you can also compute the geohash manually. Look for xkcd internet map comic and the hilbert curve to see how it works.

Why performance decline when try to mark one million marker in google map using javascript API?

it give very poor performance by using the all possibilities in javascript API. In Flash it is possible using one open source algorithm. Is there any solution to increase the performance ?
Can SVG give some solution to this?
You have a map with 1 million markers on it, and you're surprised at poor performance? You could try clustering your markers. Alternatively, only plot those that would be visible in the current bounds. Each time the bounds change, replot them.
I don't think SVG is the solution, it's vector-based and gives poor performance for many objects. Canvas would be much better compared to SVG.
If you must use 1.000.000 markers either user server-side clustering or experiment using Canvas if possible.

Easiest way to create a dynamic heatmap of the United States

thanks for all the help the last few days. I'm hoping someone knows this one.
I'm looking to dynamically create a heatmap of data based on user input, then color certain states based on the response. Like a poll for voting, for example. I'd like to do something like this...
http://www.trulia.com/home_prices/
What is going to be the easiest way to do this?
The Google Chart API also offers maps.
Here's a (completely made up) example:
Another very easy solution is OpenHeatMap.com. They support pegging data to a variety of map shapes, including US states.
OpenLayers is a javascript library for displaying tiled maps and related elements (polygon, line, etc) on top of these tiles.
It supports a number of back-ends for map data, including google's data.
Samples are available here

How to simplify (reduce number of points) in KML?

I have a similar problem to this post. I need to display up to 1000 polygons on an embedded Google map. The polygons are in a SQL database, and I can render each one as a single KML file on the fly using a custom HttpHandler (in ASP.NET), like this http://alpha.foresttransparency.org/concession.1.kml .
Even on my (very fast) development machine, it takes a while to load up even a couple dozen shapes. So two questions, really:
What would be a good strategy for rendering these as markers instead of overlays once I'm beyond a certain zoom level?
Is there a publicly available algorithm for simplifying a polygon (reducing the number of points) so that I'm not showing more points than make sense at a certain zoom level?
For your second question: you need the Douglas-Peucker Generalization Algorithm
For your first question, could you calculate the area of a particular polygon, and relate each zoom level to a particular minimum area, so as you zoom in or out polygon's disappear and markers appear depending on the zoom level.
For the second question, I'd use Mark Bessey's suggestion.
I don't know much aobut KML, but I think the usual solution to question #2 involves iterating over the points, and deleting any line segments under a certain size. This will cause some "unfortunate" effects in some cases, but it's relatively fast and easy to do.
I would recommend 2 things:
- Calculate and combine polygons that are touching. This involves a LOT of processing and hard math, but I've done it so I know it's possible.
- Create your own overlay instead of using KML in PNG format, while you combine them in the previous suggestion. You'll have to create a LOT of PNGs but it is blazing fast on the client.
Good luck :)
I needed a solution to your #2 question a little bit ago and after looking at a few of the available line-simplification algorithms, I created my own.
The process is simple and it seems to work well, though it can be a bit slow if you don't implement it correctly:
P[0..n] is your array of points
Let T[n] be defined as the triangle formed by points P[n-1], P[n], P[n+1]
Max is the number of points you are trying to reduce this line to.
Calculate the area of every possible triangle T[1..n-1] in the set.
Choose the triangle T[i] with the smallest area
Remove the point P[i] to essentially flatten the triangle
Recalculate the area of the affected triangles T[n-1], T[n+1]
Go To Step #2 if the number of points > Max