kml to encoded polyline/polygon - google-maps

The utility at http://www2.warrensburgr6.org/boundary/encoder/#details is good for converting kml files to encoded polylines for use with the Google Maps Javascript API v2. But I notice it no longer works for polygons. So I have two questions:
1) Is there anything equivalent for the Google Maps v3 API?
2) Is it still possible to use encoded polygons with the Google Maps v2 API? If so, how?
And before anyone asks, yes I know it's possible to display kml data directly. But due to the size of the files, I don't want to do so.

Question effectively withdrawn, as I've now managed to hack the encoder utility to produce v3 code.
(I'd still be interested to know whether the v2 API wrapper can be made to display the polygons, but that's really just idle curiosity).

Related

Google Maps mangling KML

I've created KML files of some world regions for display using the Google Maps API. This has been working fine, but one region has recently started displaying as if the data's corrupt. You can see what I mean here:
https://drive.google.com/file/d/0B9u3tNbtEyFRMTdwQTdEa0U5S2s/view?pli=1
If I load the same KML in Google My Maps it still displays correctly:
https://www.google.com/maps/d/viewer?mid=z8mYjxPmAgBQ.kGn7mza0JOSU
It used to display fine, but now even if I roll back to previous versions of the file it displays in this weird way.
The KML regions are created using QGIS's Vector > Geoprocessing Tools > Dissolve tool to merge countries (to shp files), which I then save off as KML. Data is from Natural Earth's ne_50m_admin_0_countries data set.
Does anyone know what might be going wrong?
I would say that the Google Maps KML rendering engine has some issues. It works when I use the geoxml3 third party parser to render it, but not when I use the Google Maps Javascript API v3 KmlLayer to render it.
rendered with geoxml3
Note that the performance with third party parsers will depend on the complexity of the KML. Tile base rendering like used in KmlLayer will almost always perform better.
issue #8003 in the Google Maps Javascript API ve issue tracker
I thought I was going crazy. This was working for years until some days ago.
I agree it seems to be where polygons cross the "international date line" or anti-meridian. I see straight lines horizontally across the map.
Furthermore I swapped out my KML file for another from a different source, SAME problem. Thanks for restoring my sanity, I wasted a stressful day trying to fix this, I think it is a Google problem. ps. they work fine in Google Earth.

Google Maps API v3 & easy methods of generating KML coordinates for overlays?

I have been looking around the google maps documentation and examples and would like to know if there is an easy method of generating coordinates for a state or country etc?
If you are looking for shape files in various formats for all kinds of features, you can have a look at the Natural earth data dataset. It is also available on Google Fusion Tables in different formats.

Google maps (API v3) with kml layer. how to hide kml URL?

I would like to di splay a Google Map with a kml inside through API v3. the proble is that every one can see the url of the kml and easily download it. Is there a trick to 'hide' the .KML URL?
wikimapia.org seems to do something similar displaing kml polygons but if you check with Firebug through the script tag you won't see the kml URL.
thanks everyone for help.
A. from Italy.
You could generate it at run time, so that the server sends the page the URL. However, it is still discoverable at some point. Security through obscurity just doesn't really work. The KMLLayer Layer requires your KML to be on a public server. You could instead parse the KML and render it that way, say using egeoxml. However that delivers much less performance.

Add point polyline polygon in google earth

I want to develop a web-application using Google Earth in the browser.
I need to add a point feature, a polyline and a polygon.
The web-applicaton needs to display the features the same as the Google Earth desktop application.
I want to use the Google Maps Api and the Google Earth Api to deliver google earth in the browser.
How can I make this kind of application for myself, what is the best way for doing so?
You should look at the Google Earth Api documentation. http://code.google.com/apis/earth/documentation/reference/
Simple objects like points, polylines and polygons can be created via the api or loaded in Kml format. Take a look at the following documents.
Geometries and Overlays
http://code.google.com/apis/earth/documentation/geometries.html
Introduction to Kml
http://code.google.com/apis/earth/documentation/kml.html
From the sounds of it the KML approach might be the easiest thing - depending on the nature of the application. If you have some existing data in Google Earth, it would be easy to save this as a kml or kmz file and load it in to the Google Earth Api.

KML overlay as string

Is there any way to create a KML overlay in Google Maps by passing the KML as a string rather than as a publicly accessible URL? AFAICT there is no such option in the Google Maps API v3. I am not asking about the API but about possible end runs around this limitation.
Personally I can think of only one: to parse the KML and generate equivalent JS. Does anyone have a better suggestion?
geoxml3 has a parseKmlString method, which will parse a string of kml and can create native google maps API v3 objects from it. I have used it to parse kml fragments out of FusionTables.
I've tried too but i haven't found a way to do this.
The reason is explained here: https://stackoverflow.com/a/6152916/2131283
For the tests my work around was sharing the kml file on my dropbox then give the direct access url with the token to the constructor
kmlLayer = new google.maps.KmlLayer
url: 'https://dl.dropboxusercontent.com/s/eg/gmaps.kmltoken_hash=HASH_CODE&dl=1'
Looking over the API it doesn't appear that this is possible.