Custom Placemark symbols used in KML not showing up in Google Maps - google-maps

This is driving me crazy. I've been developing some simple embedded Google Maps such as the following:
http://publicworks.snoco.org/rdclosures/snocordclosuregmaps.html
This map in particular has several kml overlays but one of them is no longer displaying the custom placemark icons I had developed and specified. The problem KML layer is this:
http://publicworks.snoco.org/RdClosures/SnocoRdClosures4Gmaps.kml
Some time in the last few months, the custom symbols stopped displaying and have been replaced by the default placemark symbol. If you open the KML file in Google Earth, it displays properly. The KML file does validate using KmlValidator.
Through my searches on here, I saw a suggestion about using definitions at the top of the KML file and then using within each Placemark. I made that change to my KML but it did not appear to make any difference (the custom icons are still not displaying).
I realize that KML files get cached on Google's end so if you look at my javascript code, I'm using the dummy parameter trick with my KML URL path to force a refresh of the layer. The other thing I will note is that the content of this KML is not static and it frequently changes.
Any ideas? Because I'm stumped!
THANKS!
Steve

Agreed with fragileninja that something is happening with your images between your server and Google's. The usual suspects are timing out and 404s (or other server errors).
Since the KML layer is actually being rasterized to tiles on Google's servers, the request has a relatively short timeout so the tiles aren't delayed from being sent to the browser. If the icon images aren't returned in that time, usually Maps will render using the default icon (as it's doing here). However, I also have no trouble getting the icons to work when I host them on my own server, and I don't see atrocious loading times when I access your icons directly, so it is strange.
It's possible that your servers are taking a longer than usual time to respond to Google's servers specifically, or even that they're returning some HTTP error to them instead of an image.
Can you check your server logs to see if you can see the requests and if they're returning as expected?
Finally, if there's no problem there, I would suggest filing a bug on the Maps API issue tracker. Make sure to pick the appropriate template from the dropdown list (you might also consider making a simpler test case, like just using your KML file with the KmlLayer example from the docs) . If you do end up filing a bug, please link it here and I'll make sure it's looked at.

It's something to do with how your server is serving up the images. If I host the icons on mine, it works fine, and your other KML files are using icons from maps.google.com, which also works fine.
Since it works in GE, I'm guessing maybe your server is sending the wrong MIME type or something along those lines. I checked with curl and everything looks fine though, so I'm afraid I can't offer any more details than that. Hopefully this helps get you in the right direction. Good luck!

Related

Why are my line colors not showing in my KML file on Google Maps?

I have a KML file from an architect who says he colorized the lines (white, blue, red) and I see the codes in the file itself so I know they are there. The proper colors do display in Google Earth, but NOT in google maps http://lonesomevalley.com/site-map-mapbox/ that I added as a KML layer into MapBox. They also don't display when I bring into the Geojson.io tool so something must be wrong. I see that color is supported by google maps so wondering why it isn't working. Please help! Thanks in advance! My code can be downloaded here: http://evolv.com/lonesome.kml
If I understand the question right, it was the same problem like I had for quit a while. Then someone gave me this quit simple solution.
The colorcodes in kml are in BGR format, while most other formats are the usual RGB format.
The conversion is quit simple: RGB 'ff12dd' will be in BGR 'dd12ff' (R and B just change) but in kml there must always be 'FF' in front, so it will be 'FFdd12ff'
I can't tell you if it's the same issue on your mapbox-implementation(mapbox isn't google maps)
The colors also will not be applied in a google.maps.KmlLayer
The issue seems to be that you've placed the <Style/>'s in <Folder/>'s
When you validate the KML ( http://www.kmlvalidator.com/home ) you'll see that the styles may not be found(and more errors) .
Possible solution( at least related to google-maps): Place the Styles outside of the Folders, as direct childs of <Document/>
Okay after much trial and error working within the KML file, I finally consulted an expert who gave me a simple answer that worked! He said the easiest way to go about changing line colors and weight is through MapBox Editor itself. All you have to do is click on the Data tab, then the 3 horizontal lines button ("hamburger menu drawer icon") to bring up the features. Then you can delete any feature you want from there or click on the feature to change its stroke color and weight. So EASY!!! Just be sure to hit save when done. And there is no Undo if you trash something by mistake so make sure to Save every once in a while and just back out of the project without saving in order to get back something you deleted by mistake.
So all in all I believe that KML files don't bring in the colors of lines correctly to MapBox and therefore need to be corrected through the editor itself.

Ushahidi - How to make the markers stay on the map on zoom change?

I am using the platform Ushahidi Web-2.7.3 , see: http://ti5.net.br/provedorlegal.com.br, and when I zoom in beyond a certain level, the clustered markers disappear from the map. I also tested this on an older version of a site, see: http://movimentofichalimpa.org/mapa, where the clustered markers do not disappear on zooming in, but just become ungrouped, as is normal with a cluster strategy. How can I make the markers remain on the map when zooming in?
Ushahidi actually uses OpenLayers under the hood -- the images may come from Google, but the Javascript library is pure OpenLayers. These markers are actually generated by adding what is known as a context to the style attribute of the OpenLayers.Layer.Vector and an associated Cluster.Strategy. There is a good example of it working properly here: OpenLayers cluster example and if you look at the Javascript source you will see how it is done: view-source:http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/strategy-cluster-threshold.html by defining a radius in the context of the styleMap.
The reason that your example isn't working is that there is actually a script error being triggered, which is stopping the clustering/styling from being performed. The styles are defined in the file ushahidi.js. If you open a Javascript debugger you will see the error for yourself that is firing before the ushahidi.js functions are called to determine the number of features in the cluster and therefore the radius of the markers.
The actual error is http://ti5.net.br/provedorlegal.com.br/index.php/json/cluster?s=1401591600&e=1404183599&z=9, but I have no idea why, as the OpenLayers is the minified version which is very hard to debug. You might find moving your application to OpenLayers directly will help, as it will be easier to debug, and it also works on mobiles, which I know is one of the reasons people like to use Ushahidi.

strange behavior with paths in google maps static image api

I'm trying to get a static image of a hiking trail from google maps static image API, and I'm seeing some strange behavior. Sometimes, it works pretty well and then other times, it either doesn't show the path at all or it renders it in a strange way.
Here's an example of a path which doesn't show-up the way I'd expect: jagged path
When I build a KML from these same coordinates, everything shows-up just the way that I would expect. But when it's sent to the static images API, something's getting mixed-up.
I've played around with adjusting the center of the map and the zoom with no noticeable effect. In order to fit within the URL character limit, I had to cut down on the number of coordinates in the path. I've tried adjusting the number of points in the path, but I still get a weird, jagged path instead of the one I see from my KML file.
I've also tried to remove coordinates from the above URL until I can find the culprit, but then I run into a different issue. Try this image: no points at all. You'll notice that the path doesn't show at all in this image.
Sometimes, the call works just fine (I don't get the granularity I'd like since I have to trim coordinates to with within the URL length limit - but I can live with that). You can see an example here: working example
What's going on? Am I making some simple mistake that I can't see or is this something on google's end? Thanks!
I figured it out. I wasn't escaping the URL correctly. I skimmed through the API site too quickly (found here) and when I went back and looked through the guide again, I noticed some things that I missed the first time. I was using the python url escape function which was not escaping the parts which needed escaping and escaping things which didn't need to be escaped.
Here's an example of a working path:
http://maps.googleapis.com/maps/api/staticmap?format=jpg-baseline&maptype=terrain&size=320x320&sensor=true&path=color:0xff0000ff%7Cweight:2%7C34.680923,-83.998035%7C34.682763,-83.996703%7C34.684612,-83.995759%7C34.685855,-83.994969%7C34.687478,-83.993794%7C34.689339,-83.99301%7C34.691484,-83.992649%7C34.693114,-83.991636%7C34.695631,-83.991983%7C34.697488,-83.990639%7C34.698856,-83.988732%7C34.700114,-83.986356%7C34.701881,-83.985913%7C34.703546,-83.98486%7C34.705588,-83.984205%7C34.707439,-83.985204%7C34.709409,-83.98474%7C34.710815,-83.982891%7C34.713098,-83.982932%7C34.715471,-83.981058%7C34.715643,-83.97896%7C34.716061,-83.976655%7C34.718408,-83.975622%7C34.718576,-83.972885%7C34.720504,-83.972258%7C34.722156,-83.970446%7C34.723245,-83.970965%7C34.724158,-83.968403%7C34.725936,-83.96585%7C34.727591,-83.963934%7C34.729219,-83.962787%7C34.730165,-83.960224%7C34.730464,-83.957465%7C34.731384,-83.954936%7C34.733571,-83.952937%7C34.735248,-83.951872%7C34.736235,-83.94911%7C34.738577,-83.94717%7C34.740465,-83.946156%7C34.741132,-83.943978%7C34.743225,-83.944512%7C34.745393,-83.943994%7C34.742783,-83.942916%7C34.742451,-83.941822%7C34.741552,-83.940703%7C34.740811,-83.939462%7C34.74023,-83.937804%7C34.738605,-83.936371%7C34.736056,-83.935923%7C34.734862,-83.935931%7C34.736535,-83.934433%7C34.737494,-83.932963%7C34.738196,-83.931812%7C34.737864,-83.9307%7C34.735883,-83.930629%7C34.735412,-83.928034%7C34.736785,-83.925242%7C34.737286,-83.922985%7C34.735846,-83.918937

Google Maps API KML Balloons Not Visible

I am using Google Maps JavaScript API v3 with a KML layer to display a map with custom markers.
My map links to the KML file I published as a Google Site attachment. Once loaded, the map shows each of the PlaceMarks from the KML file correctly, but will not display the popup balloons.
Rarely when I click a pin it shows the balloon (5% of the time), then none of the other pins work. When I zoom in and out my custom pin images sporadically revert to the default pin image.
I added the layerOptions to explicitly set clickable to true and suppressInfoWindows to false. It didn't change the balloon behavior.
I have tested with Chrome v19, Firefox v12, and IE8.
Update 1:
I found a typo in my KML, (bal*l*oon). Still not working right. Something is making the pins buggy.
Update 2:
v3 is now working. Google's caching made this difficult to test. Added '?nocache=0' to KML URL to prevent caching. BaloonStyle was the problem, but caching caused the typo to remain. Migrating KML to personal server.
Live HTML Map Page (Fixed)
Live KML Download (Fixed)
My references:
http://developers.google.com/maps/documentation/javascript/reference
http://ge.images.alaska.edu/workshop/advanced.htm
Google is caching your KML on purpose. The workaround is to append something like the current time to the end of your URL so that it is different every time:
var kmlFile = 'http://www.myserver.com/my.kml?'+(new Date()).getTime();
var kmlLayer = new google.maps.KmlLayer(kmlFile);
kmlLayer.setMap(myMap);
My problems:
A typo in my BalloonStyle tag
A stale cache of my KML file
This would have been easier if:
Google Maps JS threw errors when parsing KML
Google caching was reasonably fast
I started testing on a server
Update:
I moved the KML file to my server, but the cache remained stale after the first change. It seems the caching occurs when my Google Map object loads the KML overlay. I made sure it was not my system or my server caching.
The pins start acting buggy if I make a change to my KML and the cache doesn't update. All my pins show in the correct location, but one of the pins won't have a balloon. Changed the file name, works fine!
Update 2:
I reported this caching behavior as a bug on Google Maps JS API.
http://code.google.com/p/gmaps-api-issues/issues/detail?id=4196
Conclusion:
I wrote the ASP.NET/C# class to geocode addresses and build the KML doc in less time than it took to find this error.
Stop caching so hard Google!
Your KML is invalid. <Name> is not part of the spec. Change it to <name> and you should be good to go.

Custom icons in KML occasionally break in Google Maps

So this might be a bit tricky to demonstrate, since the problem only appears occasionally and unpredictably--hopefully the problem shows up when you view this question (or, alternatively, has stopped appearing altogether!).
We have a Google Maps implementation on our site that displays paginated search results on a map. The current page's results appear as regular Google Maps markers (with custom icons--these work fine), but the other search results appear as smaller markers in a KML layer. An example:
http://www.redflagdeals.com/in/verdun/map/
The large markers are squarish pin images; the small markers are coloured dots. Blue and purple markers/dots simply refer to different types of content. In the KML file, we've specified two Styles, one for each content type. Other than the Icon reference, which points to the different pin images, the two elements are exactly the same. Here's an example generated KML file for reference:
http://www.redflagdeals.com/in/verdun/map/?do=map_kml&longitude=-73.56895400000002&latitude=45.457064&order=deal_price&dir=asc&category_filter=0&content_filter=0&tag_filter=0&keyword=&page=1&show=deal%20coupon
Most of the time, our map shows the large and small markers perfectly. Occasionally, though, some or all of the small pins show up without the custom icons, instead reverting to the generic blue Google marker image. Today, the custom minipins that show up in blue are broken, while the purple ones are all fine. Other times, both the blue and purple ones are broken.
The problem usually fixes itself, leaving us clueless as to the cause or the solution. The only theory I have is that we use a CDN to host our marker images, and occasionally we push a new version to the CDN while updating all the filenames simultaneously (as we have CDN version numbers in the URLs for our images). Maybe it's possible Google is requesting one or both of the small pin images right when we're pushing a new CDN version, getting a 404, and giving up immediately. But that would mean Google caches the KML images (or lack thereof) for quite a long time. Other than that, I have no ideas.
Is there anything we can do to prevent this problem from cropping up in the future?
see this post (Comment #4 specifically) explains caching of custom markers
http://code.google.com/p/gmaps-api-issues/issues/detail?id=3864
I've just tested this, the result is the following:
I'm sure Google caches both, the KML-file and the marker-images.
(Of course they do, otherwise they must load the files and create new tiles on every single request )
So when you change any marker-image, you must change the URLs of the marker-images inside the KML-file.
You also must change the URL of the KML-file inside your application(otherwise google will not recognize the modified image-URL's)
It's sufficient to append a random parameter to the URLs