Can't display a track in Google Earth, but works fine in Google Maps - why? - google-maps

Re,
I have this strange problem... one track refuses to show in Google Earth. It displays the distance, elevation, everything, but there are no visible track lines. Importing it into Google Maps works fine.
Basically, I have a file with over 350k points. When assembling it, I separated tracks by dates and am now trying to merge them together (manually, by editing the KML file). It appears that when I try to merge placemarks with thousands of coordinates, they stop displaying in Google Earth; as if there is a limit as to how many coordinates a placemark (linestring) can contain.
Here's the file: http://www.upl.co/upload/s4Co0Gc2Q
Thanks in advance.

You need to use the <tessellate> element on the linestring. This specifies whether to allow the LineString to follow the terrain. To enable tessellation, the altitude mode must be clampToGround or clampToSeaFloor. Very large LineStrings should enable tessellation so that they follow the curvature of the earth (otherwise, they may go underground and be hidden).
The other option is to use the <gx:altitudeOffset> element. This is A KML extension, in the Google extension namespace, that modifies how the altitude values are rendered. This offset allows you to move an entire LineString up or down as a unit without modifying all the individual coordinate values that make up the LineString . (Although the LineString is displayed using the altitude offset value, the original altitude values are preserved in the KML file.) Units are in meters.
Something like this should work.
<LineString id="ID">
<extrude>1</extrude>
<tessellate>1</tessellate>
<altitudeMode>clampToGround</altitudeMode>
<coordinates><!-- lon,lat[,alt] --></coordinates>
</LineString>

I have a LineString with about 96000 coordinates, and see the same effect that I can load the KML in google-earth, and see everything correct, except for the LineString (lines are not displayed), as if I had execeeded a certain limit.
The coordinates do not have an altitude. I tried with and without tesselation and alitudeMode clampToGround.
Solution for me was to split the LineString up with a MultiGeometry, splitting it in half was sufficient (each LineString now has less than 64000k coordinates).

Related

Best way to display 100k+ points on map

I have a dataset with several hundred thousand lat/long points. I would like to render these points on a map for info-graphic purposes (as small dots or something similar).
This is not something that necessarily has to be interactive, or rendered in a browser. It's okay if it's just an image.
I know that attempting this with markers and Google maps would be tough... any other tools out there that would generate this type of map? Preferably free/open source?
Or, do you have a method to make this work with something like Google maps? I don't want to use a marker clusterer... I need to be able to see all of the points.
In short :)
Download and fire-up Quantum GIS
Add some background map (e.g. OSM WMS layer from http://129.206.228.72/cached/osm)
Have your data in a CSV file, in WKT format, and load it on top (using add delimited text layer)
Save as image
You might want to peek what stackexchange.com has on GIS, too.

KML coordinates are off in a custom Google Map?

EDIT: Turns out it was all because the coordinate translation functions in the javascript were written wrong. The author of the program has apparently fixed it.
I'm trying to use KML files to display placemarks on a custom Google Maps map. The map was generated by a Minecraft mapping program called Unmined.
My problem lies with the positioning of placemarks. They are placed on the map in a position that doesn't seem to correlate with either the pixel or latitude/longitude coordinates of the map itself.
Here is an image showing my problem.
I loaded a KML with five placemarks defined. One in the middle (0,0), one in the top-left corner (-170,80), one in the top-right corner (170,80), one in the bottom-left corner (-170,-80), and one in the bottom-right corner (170,-80). The set of markers seems to be duplicated horizontally but from my experience that's standard with Google Maps. As far as I know, the range of valid coordinates in a KML file are from -180 to 180 longitude and -90 to 90 latitude, which means that any valid placemark would have to fall somewhere inside that rectangle. Except that rectangle barely intersects the map at all.
If you need access to the code I'm using, everything can be found in the source of http://tonyfox.ws/dt/kantomap/ (URL may not exist forever)
So am I just doing something catastrophically wrong or what?
On a related note, how does Google Maps decide where to place the map in the coordinate system when the map isn't an actual Earth map (like this Minecraft world map)? My map seems to range from about 14.5 to 19.5 longitude, and 25.5 to 28 latitude. Why such weird numbers?

Horseshoe shaped polygon

I have the following kml polygon:
<Polygon><outerBoundaryIs><LinearRing><coordinates>20.002,80.002 20,80.002 20,80.004 20.006,80.004 20.006,80.001 20.002,80.001 20.002,80.002 20.004,80.002 20.004,80.003 20.002,80.003 </coordinates></LinearRing></outerBoundaryIs></Polygon>
If I view this polygon in a cell in my fusion table, in the Table View of Google Fusion Maps, it looks like this:
However, in the actual google map, in the Map View, it looks like this:
The duplicate point has been rather annoyingly dropped. I want what's shown in the first diagram above, but how should I change my polygon to get the same shape in google maps?
I also tried with an inner bound, but no luck there either:
<Polygon><outerBoundaryIs><LinearRing><coordinates>20.002,80.002 20,80.002 20,80.004 20.006,80.004 20.006,80.001 20.002,80.001 20.002,80.002 20.004,80.002 20.004,80.003 20.002,80.003 </coordinates></LinearRing></outerBoundaryIs></Polygon>
Thanks,
Barry
Self-intersecting polygons require quite a bit of extra power to draw correctly, so they are not widely supported in all 2d rendering APIs / implementations.
I suggest you work around the problem by splitting your polygon into two pieces.
Ok, I think I have the answer. I can add a tiny offset (jitter) to one of the two duplicate points in the polygon. However I must add the jitter in the correct direction otherwise the polygon becomes invalid and google no longer draws it. Looking at the previous points in the polygon loop, I should be able to establish in which direction I need to apply the jitter in.
<Polygon><outerBoundaryIs><LinearRing><coordinates>20.002,80.002 20,80.002 20,80.004 20.006,80.004 20.006,80.001 20.002,80.001 20.002000001,80.002 20.004,80.002 20.004,80.003 20.002,80.003 </coordinates></LinearRing></outerBoundaryIs></Polygon>

Around-the-world path breaking in Google Static Maps

I'm creating Google Static Maps with a path between markers and have come across certain coordinate combinations that break the path.
The path breaks in this example (markers # Beijing, SF, NY, Azores, Rome):
http://maps.google.com/maps/api/staticmap?path=color:0xff0000cc|weight:3|39.904214,116.407413|37.77493,-122.419416|40.714353,-74.005973|38.721642,-27.220577|41.89052,12.494249&markers=39.904214,116.407413|37.77493,-122.419416|40.714353,-74.005973|38.721642,-27.220577|41.89052,12.494249&maptype=terrain&sensor=false&size=640x404
And works in this example (marker # Rome removed)
http://maps.google.com/maps/api/staticmap?path=color:0xff0000cc|weight:3|39.904214,116.407413|37.77493,-122.419416|40.714353,-74.005973|38.721642,-27.220577&markers=39.904214,116.407413|37.77493,-122.419416|40.714353,-74.005973|38.721642,-27.220577&maptype=terrain&sensor=false&size=640x404
The cause is not crossing over the Greenwich Meridian as I initially thought. It breaks even if I add a marker before that, seemingly any a point East of the automatically calculated centerpoint of the map...but only when the path starts on the other side of -180 longitude.
To prove that, you can see that the Beijing, SF, NY, Azores, Rome path displays correctly when I set the map centerpoint to -170,35
http://maps.google.com/maps/api/staticmap?path=color:0xff0000cc|weight:3|39.904214,116.407413|37.77493,-122.419416|40.714353,-74.005973|38.721642,-27.220577|41.89052,12.494249&markers=39.904214,116.407413|37.77493,-122.419416|40.714353,-74.005973|38.721642,-27.220577|41.89052,12.494249&maptype=terrain&sensor=false&size=640x404&center=-170,35
Unfortunately, I can't programmatically set center like this because I never know the collection of points I'm going to get, and it would be next to impossible to detect that the passed points would cause a line break.
Any ideas?
First: you can calculate the center even if you don't know the collection of points (locations) at compile time: at runtime you know all the points (otherwise it would be not possible to insert the coordinates into the URL), therefore you can easily iterate over all the points and compute the center. You can computing the average of all coordinates and you get the geometric center (also called centroid): this is the easier way. Another way to do is to check the most distant pair of locations (for both, latitude and longitude) and then set the middle point as center: this requires slightly more coding (for instance to compute the longitude distance you need to take into account the you have to compute the distance in two directions, since it is possible to go 'around the world) and it has an higher complexity.
I don't go deeper in this topic because, even if you compute correctly the center of your points, this does NOT resolve the problem, and moreover the center provided automatically by the Google static map API is always correct: again the center is related to the problem, but it is not the (couse of the) problem.
An aspect that is trivial but important to keep in mind: Google static map draws a path between two locations always by considering the shortest path, i.e. by drawing the shortest straight line.
Therefore if you are in a situation where your path has to go from a location A to a location B, and the shortest path between A and B goes 'around the world' (or better, it goes out from one side of the image), then the path appears 'borken' as in maps that you have shown. In practice A and B are near the left and right margins of the map, and the map can not be centered in some point along the shortest path between A and B because of the others point of the path. And this is what happen when you remove 'Rome': without Rome the map can be centered in a way that the path is not borken.
Formally, I think that the problem appears (i.e. the path is broken), when the projection of the path on the equator is longer than 360 degree of longitudes, and the path always goes in the same direction (i.e. always west to east or always east to west).
Google static map in this situation simply adds another world map next to the first one: if you set the zoom to the minimum, you can see up to three world maps. This is really impractical for several reasons:
you can not zoom out infinitely;
if you want also insert markers into the map they will be drawn only on the 'main' map;
potentially you can have a path that goes around the world (passing in sequence from America, Europe, Asia, and America again and so on...) many times, and it would be really terrible to have so many little maps one after each other;
I googled a lot about this problem, and I didn't find any solution, there is a bug open on the bug tracker, but it is unsolved.
In my opinion the 'right' way to do is simply the following: at most one map and if a path has to goes out from one margin of the map/image, then it should appear on the opposite margin and continues to the destination, drawn on the same map.
So I found a first workaround:
you draw your path, and with the same style (line's color, etc) you also draw the path in a reversed way (Google static map allows to draws multiple paths in the same map), i.e. path=A|B|C&path=C|B|A and this will solve the problem in many situations (i.e. the path exits from one side of the image and enters from the other). Unfortunately this not works always: if you have a path that cross the image margin two consecutive times, then you lose a portion of your path
To solve this problem I found a second workaround:
- not draw simply the path and its reverse, but draw a different path for every pair of locations of the path (and reversed), i.e. for a path A->B->C then: path:A|B,path=B|C,path=C|B,path=B|A and this works always
The drawback is that in this way the URL becomes very long and the limit of 2048 characters for URLs is easily reached.
The best solution would be to compute manually the center, check manually where the path will cross the margin, and only for this portion of the path draw an additional path going between the two locations at the margin (and maybe also the reverse), but I do not think it really worth, although I do not think Google ever will solve this problem.

What parameters should I use in a Google Maps URL to go to a lat-lon?

I would like to produce a url for Google Maps that goes to a specific latitude and longitude. Now, I generate a url such as this:
http://maps.google.com/maps?z=11&t=k&q=58 41.881N 152 31.324W
The resulting map comes up with a round "A" balloon pointer, which seems to point to the nearest named object, and a green arrow, which points to the lat-lon. Sometimes, as in this example, the "A" pointer is centered and is far enough away that you cannot see the pointer to the lat-lon. (Zoom out to see both pointers in this example. The "A" pointer is in the center of Alaska, while the lat-long pointer is on Kodiak Island.)
Are there some parameters I can use in the Google Maps URL that will produce a single pointer to a designated lat-lon? (This loads in a separate window. It is not embedded.)
This is current accepted way to link to a specific lat lon (rather than search for the nearest object).
http://maps.google.com/maps?z=12&t=m&q=loc:38.9419+-78.3020
z is the zoom level (1-20)
t is the map type ("m" map, "k" satellite, "h" hybrid, "p" terrain, "e" GoogleEarth)
q is the search query, if it is prefixed by loc: then google assumes it is a lat lon separated by a +
yeah I had the same question for a long time and I found the perfect one. here are some parameters from it.
https://maps.google.com?parameter = value
q=
is used to specify the search query in Google maps search.
eg :
https://maps.google.com?q=newyork or
https://maps.google.com?q=51.03841,-114.01679
near=
is used to specify the location alternative to q=. Also has the added effect of allowing you to increase the AddressDetails Accuracy value by being more precise. Mostly only useful if query is a business or suchlike.
z=
Zoom level. Can be set 19 normally, but in certain cases can go up to 23.
ll=
Latitude and longitude of the map centre point. Must be in that order.
Requires decimal format. Interestingly, you can use this without q, in
which case it doesn’t show a marker.
sll=
Similar to ll, only this sets the lat/long of the centre point for a business search. Requires the same input criteria as ll.
t=
Sets the kind of map shown. Can be set to:
m – normal map,
k – satellite,
h – hybrid,
p – terrain
saddr=
Sets the starting point for directions searches. You can also add text into this in brackets to bold it in the directions sidebar.
daddr=
Sets the end point for directions searches, and again will bold any text added in brackets.You can also add "+to:" which will set via points. These can be added multiple times.
via=
Allows you to insert via points in directions. Must be in CSV format. For example, via=1,5 addresses 1 and 5 will be via points without entries in the sidebar. The start point (which is set as 0), and 2, 3 and 4 will all show full addresses.
doflg=
Changes the units used to measure distance (will default to the standard unit in country of origin). Change to ptk for metric or ptm for imperial.
msa=
Does stuff with My Maps. Set to 0 show defined My Maps, b to turn the My Maps sidebar on, 1 to show the My Maps tab on its own, or 2 to go to the new My Map creator form.
dirflg=
can set miscellaneous values below:
h - Avoid highway
t - Avoid tolls
reference
http://moz.com/ugc/everything-you-never-wanted-to-know-about-google-maps-parameters
In May 2017 Google announced the Google Maps URLs API that allows to construct universal cross-platform links. Now you can open Google maps on web, Android or iOS using the same URL string in form:
https://www.google.com/maps/search/?api=1&parameters
There are several modes that you can use: search, directions, show map and show street view.
So you can use something like
https://www.google.com/maps/search/?api=1&query=58.698017,-152.522067
to open map and place marker on some lat and lng.
For further details please refer to:
https://developers.google.com/maps/documentation/urls/guide
This should help with the new Google Maps:
https://maps.google.com/maps/place/<name>/#<lat>,<long>,15z/data=<mode-value>
The place adds a marker.
name could be a search term like "realtors"/"lawyers".
lat and long are the coordinates in decimal format and in that order.
15z sets zoom level to 15 (must be between 1 ~ 20).
You can enforce a particular view mode (map is default) - earth or terrain by adding these:
Terrain: /data=!5m1!1e4
Earth: /data=!3m1!1e3
E.g.: https://www.google.com/maps/place/Lawyer/#48.8187768,2.3792362,15z/data=!3m1!1e3
References:
https://moz.com/blog/new-google-maps-url-parameters
http://dddavemaps.blogspot.in/2015/07/google-maps-url-tricks.html
The following works as of April 2014. Delimiting each component of the URL with + and & for spaces and addition statements, respectively.
Full HTML:
<iframe src="http://maps.google.com/maps?q=Scottish+Rite+Hamilton+ON&loc:43.25911+-79.879494&z=15&output=embed"></iframe>
Broken down:
http://maps.google.com/maps?q=
where ?q= starts the general search, which I provide a venue, city, province info using + for spaces.
Scottish+Rite+Hamilton+ON
Next the geo-data. Lat and lng.
&loc:43.25911+-79.879494
Zoom level
&z=15
Required for iframes:
&output=embed
http://maps.google.com/maps?q=58%2041.881N%20152%2031.324W
Just use the coordinates as q-parameter. Strip the z and t prameters. While z should actually just be the zoom level, it seems that it won't work if you set any.
t is the map type. Having that said, it's not obvious how those parameters would affect the result in the shown way. But they do.
Maybe you should try the ll-parameter, but only decimal format will be accepted.
You can find a quick overview of all the parameters here.
If you need a name on your pin, you can also use:
http://maps.google.com/?q=MY%20LOCATION#lat,long
All the answers didn't work for me (the loc: and # options). So here is my solution for the new Google maps (April 2014)
Use the q= for query description, for example the street or the name of the place.
Use ll= for the lat, long coordinates.
You can add extra parameters like t=h (hybrid) and z=19 (zoom)
https://maps.google.com/?q=11+wall+street+new+york&ll=40.7060471,-74.0088901
https://maps.google.com/?q=new+york+stock+exchange&ll=40.7060471,-74.0088901
https://maps.google.com/?q=new+york+stock+exchange&ll=40.7060471,-74.0088901&t=h&z=19
There have been a number of changes, some incompatible, since I asked this question 5 years ago. Currently, the following works properly:
https://www.google.com/maps/place/58°41.881N 152°31.324W/#58.698017,-152.522067,12z/
The first latitude/longitude will be used for the pin location and label. It can be in degrees-minutes-seconds, degrees-minutes, or degrees. The second latitude/longitude (following the "#") is the map center. It must be in degrees only in order for the zoom (12z) to be recognized.
For terrain view, you can append "data=!4m2!3m1!1s0x0:0x0!5m1!1e4". I can find no documentation on this, though, so the spec could change.
New Version queries have a different format
To reach a lat long by url use (e.g.)
https://www.google.com/maps/search/-15.924,-5.719
works fine
https://maps.google.de/maps?q=51.404989,13.091751&z=17&t=k
This doesn't have to be much more complicated than passing in a value for the 'q' parameter. Google is a search engine after all and can handle the same stuff it handles when users type queries into its text boxes
"maps.google.com?/q=32.5234,-78.23432"
This works to zoom into an area more then drop a pin:
https://www.google.com/maps/#30.2,17.9820525,9z
And the params are:
#lat,lng,zoom
If you only have degrees minutes seconds you can pass them on the url :
https://maps.google.com/maps?q=latDegrees latMinutes latSeconds longDegrees longMinutes longSeconds
substitute in %20 for the spaces
"ll" worked best for me, see:
http://mapki.com/wiki/Google_Map_Parameters (query reference)
it shall not be too hard to convert minutes, seconds to decimal
http://en.wikipedia.org/wiki/Decimal_degrees
for a marker, possibly the best would be ?q=Description#lat,long