Hi
I'm having some issues with KML performance. At some times the KML markers only appear after a reload which may have to do with google caching the results. I think a better solution is needed perhaps something like displaying a total of markers for an area on a larger zoom level and then more detailed for levels that have more zoom. Is such a solution feasible and if so, how? Can you think of other ways how I can improve performance of my KML map? The links are http://www.koolbusiness.com and the KML file is http://www.koolbusiness.com/list.kml
I can load the KML file into maps.google.com with no problem however when trying to display it on my custom map the display sometimes won't load.
Thanks in advance for any suggestions.
UPDATE: I've updated to using a KMZ file with zip compression. The file is available via http://www.koolbusiness.com/list.kmz and the source and more info is available at http://montao.googlecode.com
don't know if it affects performance but it seems like you need to configure the mime types for kml files.
http://code.google.com/apis/kml/documentation/kml_tut.html#kml_server
Have you tried to compress the kml files as kmz files? You can do this with a zip program and just call the file kmz.
You repeat the style element in the placemarks but you can also create them under the doucment element and then just reference them with an id. http://code.google.com/apis/kml/documentation/kmlreference.html#style
I'm not sure if you've changed the KML yet to conform to some of the previous suggestions but...
The KML File seems to be pretty minimal which is good. I was going to suggest truncating the decimal points on the lat/lng.
You can compress like KML file to KMZ like the previous poster has mentioned. More information can be found here: http://code.google.com/apis/kml/documentation/kml_tut.html#kml_server You'll need to set up the KMZ MIME type on your server too.
You can reduce the amount of white space in your KML file. It seems to have additional spaces when not required...
You can configure your web server to send cached versions of the KML file... I'm not sure what kind of back end you're running though so I can't really give pointers. This might be a reason why the markers don't show. Google's server will time out your request if it takes too long.
As for your question about a solution to displaying total markers in an area for a zoom:
I was thinking you could for each zoom level, check the boundary of the map and then only display markers that have coordinates in that boundary. You'd probably have to write some kind of function that checks if it's in the boundary. I don't know of any way to retrieve the markers from the KML file as objects unless you manually parse the KML yourself using a client side parser.
To help determine why your markers don't load, try using FireBug to determine the requests to Google's servers. And see what kind of response is returning which might lead to more answers to your problem. I believe the one you should look for is KmlOverlayService.
Hope that helps.
Related
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
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.
Suppose i searched for ATM's in india, How can i get the coordinates of all the points in the map...?
I found one of the solution as getting kml file and from there i can parse it...but when i added &output=kml to the link...i am unable to get the kml file...not even kml file option.
URL after appending &output=kml
Please can any one help me in solving this...
I clicked the link you provided and I was able to download the KML file. I then opened the KML file in Google Earth which showed all the ATM's in India. I was then also able to find all the coordinates of each ATM.
See this screen shot-
Surprised why that wasn't possible with you..
output=kml no longer works. It was removed (probably because of abuse). You can get some of the ATM's using the Places API, but the results are limited to 60, returned 20 at a time.
I've been trying to get a simple example working where a kml layer within the google map will automatically update the contents on each zoom/pan. I've been testing using a simple server php file that returns a placemark in the middle of the specified bbox; our goal is to use this model to perform server side clustering. I've got the sample working in google earth using a php file linked through network kml.
Network KML file:
http://crv.vividsolutions.com/test/kml/layer2.kml
When I added the same network kml as a layer in google maps the php file on the server was only accessed the first time. The layer came up as expected and displayed the point in the middle of the screen, however after panning the map the data was not refreshed (the point was not moved to the center of the map). Based on the access logs, a bbox was passed down to the kml server with the first request, however there were not any subsequent requests. My test map can be found here:
http://crv.vividsolutions.com/test/kml/index.php
I've located an issue which looks to be related (id=2697). [I could only include 2 links on this post otherwise would have linked it].
After trying a couple things, I did manage to get the desired behaviour however the solution involves dropping the existing JS layer object and adding a fresh on every pan. This seems a bit heavy handed. I was hoping someone might have an alternative solution to get the same behaviour without the overhead associated with creating a new Layer object on each pan/zoom.
Layer swap example (works but clunky): Same server as index.php ... just rename to index2.php [ran into the smap bot link limit].
The KML reference says onStop is supported in google maps.
original link (no longer valid)
updated link
partially "onStop" is supported
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 :)