The definitive solution to your problem is to extend the Polyline class
defining the getPosition method.
This is a very simple implementation which returns the first point,
google.maps.Polyline.prototype.getPosition = function() {
return this.getPath().getAt(0);
}
maybe someone wishes to write a more sophysticated algoritm to compute the
central point of the line or the centroid of its enclosing polygon or
whatever. It won't be that easy, but is a well known GIS algorithm.
Cheers, Davide
PS The same is true for Polygon.
2010/5/27 Davide Cremonesi <[email protected]>
> Hi there,
> I see some points you could correct:
>
> google.maps.event.addListener(flightPath, 'click', function(event) {
> infowindow.content = "x";
> infowindow.position = event.latLng;
> infowindow.open(map);//,flightPath);
> });
>
> 1) the callback function must have an "event" argument, otherwise it will
> be undefined
> 2) the property of event is latLng and not latlng (note the upperCase)
> 3) the flightPath is not a good MVCObject for the infoWindow.open function.
> Maybe you could use a point of the path
>
> Hope it helps,
> Cheers
> Davide
>
>
> 2010/5/27 sb <[email protected]>
>
> I am trying to get an infowindow open on the click of a polyline.
>>
>> The event is being triggered but I am unable to get the infowindow to
>> display. I have no trouble doing this with a marker so there must be
>> something slightly different I am missing.
>>
>> Here is an example of what I am trying to do
>> http://srsz750.appspot.com/api3/polyline-simple.html
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Maps JavaScript API v3" group.
>> To post to this group, send email to
>> [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<google-maps-js-api-v3%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>>
>>
>
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.