Larry,

1: 'projection_changed' fires when the map module loads and binds the
MapType.  Until that point the JS doesn't know the Projection that will be
used.
2: the if(!projection) will happen if the MapType is set back to
null/undefined.  This is probably unusual so it is defensive programming.
3: this will work at all scales.  It never interpolates across the dateline
though, which can be fixed by checking if it is shorter to cross the
dateline then unwrapping the longitudes before projecting.
I'm not sure of the exact definition of a thumb line, it's possible Mike's
code is correct for a different purpose.  I'd need to look it up.

Cheers
Ben

On 27 Aug 2010 22:43, "[email protected]" <[email protected]> wrote:
> On Aug 26, 10:12 pm, Ben Appleton <[email protected]> wrote:
>> On Fri, Aug 27, 2010 at 2:59 PM, [email protected]
>> <[email protected]>wrote:
>>
>>
>>
>> > On Aug 26, 9:53 pm, "[email protected]" <[email protected]>
>> > wrote:
>> > > On Aug 26, 9:26 pm, Ben Appleton <[email protected]> wrote:
>>
>> > > > On Fri, Aug 27, 2010 at 2:17 PM, [email protected]
>> > > > <[email protected]>wrote:
>>
>> > > > > On Aug 26, 7:49 pm, xf_aicn <[email protected]>
>> > wrote:
>> > > > > > Hi all,
>>
>> > > > > > Now i'm doing a project that connect two place with a
>> > > > > > polyline(geodesic is true), and then at the same time, show a
>> > marker
>> > > > > > on the middle of the polyline, how can I do this? I can't get
the
>> > > > > > coordinate on thepolyline
>>
>> > > > >http://www.geocodezip.com/v3_polyline_example_geodesic.html
>>
>> > > > > Seems to be off the "native" google geodesic polyline.  Don't
know
>> > > > > why.
>>
>> > > > The geodesic marker looks OK me in Chrome/WinXP.  I've attempted to
>> > attach
>> > > > an image, though I do not know if groups allows attachments.
>>
>> > > > In which browser are you seeing the problem?
>>
>> > > IE6 (and Chrome, FF; Opera doesn't seem to want to show the map), but
>> > > click on the marker then "zoom in" to see the difference in the
>> > > polylines (the green polyline is the "native" google maps one, the
red
>> > > is the one that was calculated).  How are the "native" geodesic
>> > > polylines rendered?
>>
>> > Oops, missed this part of your question:
>> > > For the "normal" polyline did you average in LatLng space or
projected
>> > > coordinates?  I couldn't spot it at a glance of your code.
>>
>> > I just ported Mike Williams' epoly GetPointAtDistance, which just does
>> > a a linear interpolation on lat and lng.
>>
>> > Do you have a reference to a more accurate way?
>>
>> Try something along these lines (no pun intended):
>>
>> var map = new google.maps.Map(...);
>> var startMarker = new google.maps.Marker(...);
>> var endMarker = new google.maps.Marker(...);
>> var midMarker = new google.maps.Marker(...);
>>
>
> Ben,
> Some questions on this:
> 1. What causes the projection_changed event to fire? Is that always
> going to fire on map initialization?
> 2. Is the "(!projection) return", just there as good programming
> practice? Or is it likely that there won't be a projection in a
> "normal" v3 google map?
> 3. Will this work at all scales? Or is it better to use it only in
> some cases? I'm wondering if I should use it in my port of Mike
> Williams' epoly extension for better accuracy.
>
> Thank you,
> Larry
>
>> google.maps.event.addListener(map, 'projection_changed', function() {
>>   var projection = map.getProjection();
>>   if (!projection) return;
>>
>>   // Project
>>   var startLatLng = startMarker.getPosition();
>>   var endLatLng = endMarker.getPosition();
>>   var startPoint = projection.fromLatLngToPoint(startLatLng);
>>   var endPoint = projection.fromLatLngToPoint(endLatLng);
>>
>>   // Average
>>   var midPoint = new google.maps.Point(
>>       (startPoint.x + endPoint.x) / 2,
>>       (startPoint.y + endPoint.y) / 2);
>>
>>   // Unproject
>>   var midLatLng = projection.fromPointToLatLng(midPoint);
>>   midMarker.setPosition(midLatLng);
>>
>> });
>>
>>     -- Larry
>>
>>
>>
>> > > > The center marker on the "normal" polyline seems off as well.
>>
>> > > > For the "normal" polyline did you average in LatLng space or
projected
>> > > > coordinates?  I couldn't spot it at a glance of your code.
>>
>> > > > >  -- Larry
>>
>> > > > > --
>> > > > > 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]><google-maps-js-api-v3%2B
[email protected]><google-maps-js-api-v3%2B
>> > [email protected]>
>> > > > > .
>> > > > > For more options, visit this group at
>> > > > >http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>>
>> > > >  geodesic_markers.PNG
>> > > > 116KViewDownload
>>
>> > --
>> > 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]><google-maps-js-api-v3%2B
[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]<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.

Reply via email to