Can I manipulate a KML using Google Maps API v3? - google-maps

I'm loading a KML using KMLLayer in Google Maps API v3. Is it possible to reference the polygons on the map and do things like change color or transparency?

No you can't do it like that since there are no polygons like objects in a kmllayer. From the google docs:
The Maps API converts the provided geographic XML data into a KML
representation which is displayed on the map using a V3 tile overlay.
This KML looks (and somewhat behaves) like familiar V3 overlay
elements. KML and GeoRSS point elements are rendered as
markers, for example, elements are rendered as polylines
and elements are rendered as polygons. Similarly,
elements are rendered as rectangular images on the
map. Importantly, however, these objects are not Google Maps API
Markers, Polylines, Polygons or GroundOverlays; instead, they are
rendered into a single object on the map.
This page might be helpfull in exploring alternatives

Related

Can Google Maps show 3D KML objects?

Unable to let Google Maps show my imported 3D KML objects in 3D
I can import a KML file to "My Maps", but when I go to Google Maps, My maps, to view the KML file, I only get to see a "flattened" version where everything is projected onto the ground.
Can anybody tell me if (and how?) it is possible to convince Google Maps to show my imported 3D objects in 3D?
Google Maps can not show 3D KML objects, nor 3D Models, like Earth can. The Google Maps Platform documentation has a page on using KML and GeoRSS Layers in Maps, with a list of Supported KML elements. In there, you'll see that both the and elements are not supported, so no 3D in Maps, unfortunately.

KML <IconStyle> Tag is not working in google map

I have a KMl file with some multigeometries. When I import this KML file in Google Earth it looks like this image.
But when I Import same KML in Google Map is shows Like This
In Place of Lable it shows default blue color icon.
this is My Sample KMl for One Multigeomety
<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2"><Document><Style id="Yellow"><IconStyle><scale>0</scale></IconStyle><PolyStyle><color>6414F0FF</color></PolyStyle></Style><Placemark><styleUrl>#Yellow</styleUrl><name>0,15</name><MultiGeometry><Point><coordinates>-97.04983000000001,32.81053</coordinates></Point><Polygon><outerBoundaryIs><LinearRing><coordinates>-97.05083000000002,32.81083 -97.04667,32.81083 -97.04667,32.8075 -97.05083000000002,32.8075 -97.05083000000002,32.81083</coordinates></LinearRing></outerBoundaryIs></Polygon></MultiGeometry></Placemark></Document></kml>
I have already googled so many time, Please help on this.
Google Maps has issues with MultiGeometry placemarks.
If want label from the point and use Polygon then best to have separate placemark for Point with LabelStyle/IconStyle and another for the Polygon. Google Earth has no such issue with MultiGeometry features.
UPDATE:
Using Google Maps KmlLayer does not allow the label names to appear on the map - label only appears when click on placemark icon. If you want to stay with Google Maps then you might try geoxml3 library to parse the KML then enumerate the placemark and create Markers using Google Maps API. Alternately, can use Openlayers or Cesium to parse KML and display correctly.

Loading kml markers above polygon

I am working with a google map api 3, on my map i want to generate kml markers after polygons, but it is not working, my markers are generate before polygons so i am not able to click marker.
Native Google Maps Javascript API v3 polygons will always appear on top of KML layers. If you want to control the order, use a KmlLayer to display the polygon as well, add that layer first or control the order with the zIndex property of the KmlLayers.
related question: https://stackoverflow.com/questions/35455830/kml-ordering-in-google-maps-api (including example)

Getting coordinates of polygon areas defined in KML

I have displayed a google map using a KML file as source. The map has a number of polygon areas marked in it. Is there any way to get the center coordinates of each of the polygons without the click event ? I need to display an info window above each polygons when the map is displayed.
Thanks
google.maps.KmlLayer is uses tile based rendering, you can't (at least at present) access the coordinates of the polygons except on a click.
You could use:
FusionTablesLayer, import your KML into that, then query it using either a Fusion Tables API v1.0 or a google.visualization (GViz) query) for the coordinates to get their center.
example using FusionTablesLayer and GViz
A third party KML parser like geoxml3 or geoxml-v3 to render the polygons as native google.maps.Polygon objects, and get their center. This will have performance issues with complex KML.
example using geoxml3

Alternatives to Google Static Maps when the URL gets too big

My end goal is view and print a document (eg, PDF) with business-specific info on it along with a map. The map must have
The aerial imagery background
The features from a KML file.
Google Static Maps works perfectly for this until the KML gets too complex to fit in the URL. I've already shrunk the URL by reducing long/lat precision and encoding the polylines.
Ideas:
I could get the aerial imagery from Google Static Maps, then programmatically draw my KML features onto it, but I'm not sure if that's allowed in the Google Maps Terms of Use.
Are there other ways to coerce static maps to give me what I want?
Does Google have a different mapping service that could ultimately convert a KML into an image with the aerial image background?
Any non-Google services that might help?