Kml/kmz markers misplaced on map.

936 views
Skip to first unread message

az az

unread,
Jun 22, 2012, 7:17:00 AM6/22/12
to google-map...@googlegroups.com
Hi
I have a kmz file with markers (points) they used to be put on map OK 2 day ago. 
Now they are misplaced by some distance.
Here is waht I mean:


in the center of the map there is a pin with number 2 on it.

On the left hand side there is a yellow box with some names in it. The first is 'Vasil'. There is an eye icon next to it. If you click it you will see an arrow that drops on the map. 
Now the arrow is a bit misplaced compared to the pin. It must be on top of it instead.

The eye icon calls this:

onclick="addMarker(53.82606610334190123,-1.50467414437569991);

and these are the coordinates in the kmz file for this pin as well:

<Placemark><name>LS82JB</name>
<description>LS82JB</description>
<styleUrl>#a2</styleUrl>
<Point><coordinates>-1.50467414437569991,53.82606610334190123,0</coordinates></Point>
</Placemark>

The question is why the kmz is not positioned correctly on the map and a marker is?

Thanks

Andrew Leach

unread,
Jun 22, 2012, 7:47:25 AM6/22/12
to google-map...@googlegroups.com
On 22 June 2012 12:17, az az <left...@bgnet.bg> wrote:

> Now the arrow is a bit misplaced compared to the pin. It must be on top of
> it instead.
>
> The eye icon calls this:
>
> onclick="addMarker(53.82606610334190123,-1.50467414437569991);
>
> and these are the coordinates in the kmz file for this pin as well:
>
> <Placemark><name>LS82JB</name>
> <description>LS82JB</description>
> <styleUrl>#a2</styleUrl>
> <Point><coordinates>-1.50467414437569991,53.82606610334190123,0</coordinates></Point>
> </Placemark>
>
> The question is why the kmz is not positioned correctly on the map and a
> marker is?

The relationship between the two markers (the small golf-ball and the
large arrow) remains constant no matter how the zoom level is altered.
That means that the two markers are anchored to the same location on
the map, but the anchor-point of one or both of them is not in the
obvious place.

Either your large arrow does not have its anchor-point specified at
its tip, or your numbered marker doesn't have its anchor-point at its
tip, or both.

KML generally assumes that the anchor-point is in the middle at the
bottom, so that marker is probably right.

The image you use for your large arrow does appear to have a large
amount of white space between the arrow and the bottom border, so the
API is doing its best -- it's assumed that the anchor-point is at the
centre of the bottom edge. To use an arrow image like yours, you need
to fully specify the MarkerImage in order that you define the anchor
point. https://developers.google.com/maps/documentation/javascript/reference#MarkerImage

az az

unread,
Jun 22, 2012, 8:04:42 AM6/22/12
to google-map...@googlegroups.com
Just noticed one more thing: now the kml points are moving on the map depending on the zoom level. 
This is certainly wrong. See attached images

As for the anchor points - it was working OK before. So it is not that. The white space in the marker icon is intended so the arrow is on top of the kml point. 
ls81.jpg
ls82.jpg

Andrew Leach

unread,
Jun 22, 2012, 8:12:05 AM6/22/12
to google-map...@googlegroups.com
On 22 June 2012 13:04, az az <left...@bgnet.bg> wrote:
> As for the anchor points - it was working OK before. So it is not that. The
> white space in the marker icon is intended so the arrow is on top of the kml
> point.

KML handling of markers has recently changed. Your markers must be
correctly and completely defined. Currently they aren't.

If it's still wrong when your markers are complete and correct, then
there's a bug. But you can't say it's behaving contrary to the
documentation unless you rule out every other possibility.

az az

unread,
Jun 22, 2012, 8:30:00 AM6/22/12
to google-map...@googlegroups.com, andrew....@gmail.com
Hi
thanks.

I think we are mixing thing here. 
When I say marker I mean the thing which drops when you click the eye icon. This is marker by definition
When I say point I mean the point generated from the kml and overlaid on the map. This is overlay by definition.

Now, the marker is in the right spot.

The point isn't. Also the point moves on map when you zoom in/out.

 When you say 'KML handling of markers has recently changed.', do you mean  'handling of markers has recently changed. ' without KML?

az az

unread,
Jun 22, 2012, 10:20:01 AM6/22/12
to google-map...@googlegroups.com
Hi all

it is sorted now. It was the lack of 
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>

in my kml file. It seems it is now kind of required, so the placemark is positioned properly.

The style is now.

<Style id="sh_ylw-pushpin">
<IconStyle>
<scale>1.3</scale>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
</Icon>
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
</IconStyle>
</Style>

On the other note. Scale now works. I seem to remember it wasnt before.

Joseph Elfelt

unread,
Jun 26, 2012, 1:20:32 PM6/26/12
to google-map...@googlegroups.com
Two of my users reported the same problem to me at about the same time that az az noticed this.

1.  If Google has intentionally changed how it will parse KML for purposes of the Maps API, then has Google documented that change anywhere?

2.  I made this example:
KML file: http://www.mappingsupport.com/p/demo_maps/kml_test_03.kml
Small test map: http://www.mappingsupport.com/p/demo_maps/bondi_13.html

Please zoom out a bunch.

There are 3 markers on the map: red, blue and green.
All 3 markers have the same latlng.

Red marker:  hardcoded in html
Blue marker: in KML file but no <href> tag specified
Green marker: in KML with <href> tag

The green marker is not in the correct location.  If you zoom in/out the green marker remains a fixed
number of screen pixels away from the correct location.

3. If you import the KML file into Plain Old Google Maps (POGM) then the green marker is in the correct
 spot. In fact, in POGM you only see one marker (I forget which one) since the blue and green markers
are on top of each other.

4. Here is the bug report I filed with Google:
http://code.google.com/p/gmaps-api-issues/issues/detail?id=4232&q=apitype%3AJavascript3&sort=-id&colspec=ID%20Type%20Status%20Introduced%20Fixed%20Summary%20Internal%20Stars
At least so far Google has not indicated this is a new 'feature'.
If this issue is important to you, please add your star to this issue.

5. The KML spec for <hotSpot> says:
"<hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction">
Specifies the position within the Icon that is "anchored" to the <Point> specified in the Placemark. The x and y values can be specified in three different ways: as pixels ("pixels"), as fractions of the icon ("fraction"), or as inset pixels ("insetPixels"), which is an offset in pixels from the upper right corner of the icon."

Thus, if <hotSpot> is not specified the spec seems to say that the icon will be positioned with its "upper right corner" at the latlng.  However, that is not how the API KML parser has worked prior to June 22 or afterwards.  Assuming your KML includes <href> tags, then prior to ~June 22nd the middle of the bottom edge of your icon was the default anchor point.  After ~June 22 the default anchor point appears to be a fixed number of pixels to the right of the lower right corner of your icon.

Joseph Elfelt

unread,
Jun 28, 2012, 9:20:40 AM6/28/12
to google-map...@googlegroups.com
Dear Google,

Thank you for attempting to fix this problem.  However, there is still a bug in your KML parser.

Today it appears that your KML parser is using the middle of the image as the anchor point for the green <href> marker in the KML file.
I updated the small example map by adding code to avoid your KML cache:
http://www.mappingsupport.com/p/demo_maps/bondi_14.html

Please make another tweak to you KML parser so it works the way it did prior to ~June 22.
The anchor point for KML <href> markers should be the middle of the bottom edge of the image.

az az

unread,
Aug 29, 2012, 11:58:46 AM8/29/12
to google-map...@googlegroups.com
It seems there is a problem again. The markers on the map move around with every zoom in/out.
E.g. a marker on an island looks in the ocean when zoomed out and in the waterfront street when zoomed in.
I have 
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
but they move.
This wasn't the case when I added the hotspot.
Anyone noticed this again?
Reply all
Reply to author
Forward
0 new messages