KML file from Massachusetts GIS - display in Google Maps API - google-maps

I've been pulling KML files from the Mass GIS service via their export feature:
http://maps.massgis.state.ma.us/map_ol/oliver.php
For example, a KML output of Population Density per Square Mile looks like this when exported:
http://evrkusd.fatcow.com/populationpersquaremile.kml
I try to add it to my Google Map and nothing shows up, although this code works fine with other kml files from other sources.
var NewLayer = new google.maps.KmlLayer('http://evrkusd.fatcow.com/populationpersquaremile.kml');
NewLayer.setMap(map);
I'm getting the idea that some of the kml tags are outdated or are not accepted by Google Maps API.
Is anyone able to get this file to work for them? Any ideas how I can (preferably easily) update this file to work with Google Maps? I'm going to be using multiple KML files like this, so I'm hoping I can do a fairly quick fix.

Your KML file is still too big:
http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.html?filename=http://www.geocodezip.com/geoxml3_test/populationpersquaremile.kml
If you click on the "load KmlLayer" button, it will show you the status return by attempting to load that file in KmlLayer:
Kml Status:DOCUMENT_TOO_LARGE
Your "partial" KML files are not valid xml, if I make the one you posted valid, it works with geoxml3, but the Google Maps API v3 KmlLayer still says it is too big.
See the documentation, the maximum fetched size of a raw KML file is 3M, your file is 7M+.

Fusion Tables can handle much larger KML than client-side maps, up 100MB total (though some limits apply to features). So that might be a solution.

Related

How can display a little KML 3.5MB file on Google Maps but with around of 1 million of Points

I have a little problem, I'm work on a map with politic division, but when I try to load the KML file in Google Earth work fine, then I publish this KML and I try to use them in Google Maps, but not work, I read that Google Map have some restrictions, like size of files, and limit of Points, but then How I can display correctly my Map, I also have the data in a DataBase.
In this moment, I'm using FusionTables and work very well, but in my job don't want use FusionTables.
I have some option? (Server Side Processing, Load some KML instead of one or something)
thanks in advance.
Excuse me for my English.
You can:
try a KMZ file (raw KML in a KMZ can be bigger, up to 10MB)
use a third party KML parser (no limits on size, but may have performance problems)
break your KML into multiple files that meet the restrictions.
KML reference on limits, looks to me like a KMZ (compressed KML) file will work for the data you have described.
Maximum fetched file size (raw KML, raw GeoRSS, or compressed KMZ) 3MB
Maximum uncompressed KML file size 10MB

Download full KML from Google Maps

I have Google Map with about 1200 points. When I try to save it as KML or view in Google Earth there is only 1000 point. Is there a way (for example using some API) to download all points (I don't need KML - I just want coordinates with description - it may be in some other format)?
Map can be found here. When you save KML there will be no points from 6th page.
Apparently there is a 1000 feature limit on exports from My Maps:
Restrictions
#4. There is a 1,000 feature limit on a single My Maps export, and approximately 1,000
in displaying KML - so large maps wont particully benefit from this trick. Wont show an
error just the first 1000 points/lines/features.
See this post on the google map product forum for a workaround to export all the points, Barry Hunter also recommends (and I concur) using FustionTables if you need to display more points on a map (sounds like you don't need to display them on a map, just retrieve the data from your map).
Seems to work, here is a combined file displayed on Google Maps (goes up to 1193)
geoxml3 reports 1197: geoXmlDoc: Object -> placemarks: Array[1197]

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.

Importing CSV File to Google Maps

I have an quite big CSv File I want to have in Google Maps or just on a map. These are just coordinates but I have 600.000 of them..
Do you have any Idea how I can do this?
I've added an screenshot from XTabulator below:
We have now (jan2017) a csv layer import inside Google Maps itself.
Google Maps > "Your Places" > "Open in My Maps"
GPS Visualizer has an interface by which you can cut and paste a CSV file and convert it to kml:
http://www.gpsvisualizer.com/map_input?form=googleearth
Then use Google Earth. If you don't have Google Earth and want to display it online I found another nifty service that will plot kml files online:
http://display-kml.appspot.com/
none of that needed.... just go to:
http://www.gpsvisualizer.com/
now and load your csv file as-is. extra columns and all. it will slice and dice and use just the log & lat columns and plot it for you on google maps.
The easiest way to do this is generate a KML file (see http://code.google.com/apis/kml/articles/csvtokml.html for a possible solution). You can then open that up in Google Maps by storing it online and linking to it from Google Maps as described at http://code.google.com/apis/kml/documentation/whatiskml.html
EDIT: http://www.gpsbabel.org/ may let you do it without coding.
For generating the KML file from your CSV file (or XLS), you can use MyGeodata online GIS Data Converter. Here is the CSV to KML How-To.

Can I show a single country (masked out) in GoogleMaps?

Is it possible to mask away neighbor countries in GoogleMap? In my case I just want to show Sweden on one view. On a second view just Norway, Denmark etc etc...
I know it is possible to draw polygon lines and fill them accordingly on to Maps API. Problem is that or the result sets get huge or the lines get very rough etc... Would be nice if GoogleMaps could deliver a country at the time without neighbors.
Does anyone know about a good coordinate database with country borders?
You can create very complex polygons in Maps without a drop in performance if you store them in KML file format and load them as KmlLayers. KML is an XML based vector file format for geo data. The beauty of using KML files in Google Maps is that they are rendered on Google servers into simple PNG files, matching the current resolution and bounding box of your Maps view at any time, no matter how complex the original polygon data is. So all complexity is handled server side at Google.
Here is a sample of a project, where I have used such a masking for one of the federal states of Germany. (The surroundings in this case are not fully masked away but only dimmed. But you can also mask them off just as easily by changing the alpha value of the fill color in the KML file.)
For a quick review KML files can also be loaded directly into the Google Maps public website (by entering their URL into the search field). Here is the KML file that I have used in the above project, loaded directly into Google Maps. (I have actually used a KMZ file here, but that is simply a KML file packed into a ZIP archive. You can pack and unpack it with normal ZIP tools.) BEGIN UPDATE 07/2015: Unfortunately Google has REMOVED the possibility to directly enter the URL of a KML/KMZ file into the search field of their public Google Maps when they launched its redesigned version in 2014. You can still use all techniques discussed in this answer but you cannot simply preview KML files by entering their URL in the search field anymore. If you need the KMZ mentioned above for further analysis, you can download it here. END UPDATE
Please be aware that Google implies a size limit to KML/KMZ files (currently 10 Mb uncompressed, 3 Mb compressed - details see here). If your KML files should be to large, there is software available to reduce the complexity (see examples here and here).
You will find free map data at many places on the Internet, most of them being in ESRI shapefile format. A great source for country maps is http://www.gadm.org/ with the big advantage of providing their data in KML/KMZ format too. If you should have to convert ESRI shapefiles to KML, have a look at the great (and free) OGR converter.
Please notice that KML files are only a solution if your polygons are static (like the border of Sweden is) and not depending on any user input. For dynamic polygons you will still have to use the Polygon class of the Maps API with the complexity restrictions that you have mentioned.
had a similar problem and managed it by combining gamps with fusion tables:
var table_id = 420419; //can be exchanged wit another table
var FT_Query = "SELECT 'kml_4326' FROM "+ table_id +" WHERE 'name_0' NOT EQUAL TO 'SWEDEN'";
var FT_Options =
{
suppressInfoWindows: true,
query: FT_Query
};
var layer = new google.maps.FusionTablesLayer(table_id, FT_Options);
layer.setMap(map);
Have you considered loading in a custom map?
I haven't used it myself, but hopefully that link could help you out a bit :)