Polyline Geodesic

1,098 views
Skip to first unread message

xf_aicn

unread,
Aug 26, 2010, 10:49:39 PM8/26/10
to Google Maps JavaScript API v3
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

geoco...@gmail.com

unread,
Aug 27, 2010, 12:17:44 AM8/27/10
to Google Maps JavaScript API v3
http://www.geocodezip.com/v3_polyline_example_geodesic.html

Seems to be off the "native" google geodesic polyline. Don't know
why.

The center marker on the "normal" polyline seems off as well.

-- Larry

Ben Appleton

unread,
Aug 27, 2010, 12:26:08 AM8/27/10
to google-map...@googlegroups.com
On Fri, Aug 27, 2010 at 2:17 PM, geoco...@gmail.com <geoco...@gmail.com> wrote:
On Aug 26, 7:49 pm, xf_aicn <xiaofan.zh...@asiainspection.com> 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?

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 google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


geodesic_markers.PNG

geoco...@gmail.com

unread,
Aug 27, 2010, 12:53:25 AM8/27/10
to Google Maps JavaScript API v3
On Aug 26, 9:26 pm, Ben Appleton <apple...@google.com> wrote:
> On Fri, Aug 27, 2010 at 2:17 PM, geocode...@gmail.com
> <geocode...@gmail.com>wrote:
>
> > On Aug 26, 7:49 pm, xf_aicn <xiaofan.zh...@asiainspection.com> 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?

-- 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
> > google-map...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2B unsub...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>  geodesic_markers.PNG
> 116KViewDownload

geoco...@gmail.com

unread,
Aug 27, 2010, 12:59:22 AM8/27/10
to Google Maps JavaScript API v3
On Aug 26, 9:53 pm, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
> On Aug 26, 9:26 pm, Ben Appleton <apple...@google.com> wrote:
>
>
>
> > On Fri, Aug 27, 2010 at 2:17 PM, geocode...@gmail.com
> > <geocode...@gmail.com>wrote:
>
> > > On Aug 26, 7:49 pm, xf_aicn <xiaofan.zh...@asiainspection.com> 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?

Ben Appleton

unread,
Aug 27, 2010, 1:04:50 AM8/27/10
to google-map...@googlegroups.com
On Fri, Aug 27, 2010 at 2:53 PM, geoco...@gmail.com <geoco...@gmail.com> wrote:
On Aug 26, 9:26 pm, Ben Appleton <apple...@google.com> wrote:
> On Fri, Aug 27, 2010 at 2:17 PM, geocode...@gmail.com
> <geocode...@gmail.com>wrote:
>
> > On Aug 26, 7:49 pm, xf_aicn <xiaofan.zh...@asiainspection.com> 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?

Oh interesting: if the green line is the native geodesic then it appears slightly off compared to the red line.  At least one of them is wrong - I'll take a look.
 
 -- 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
> > google-map...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2B unsub...@googlegroups.com>
> > .
> > 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 google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
geodesic_markers_zoomed_in.PNG

Ben Appleton

unread,
Aug 27, 2010, 1:12:33 AM8/27/10
to google-map...@googlegroups.com
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(...);

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
> > > google-map...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2B unsub...@googlegroups.com>
> > > .
> > > 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 google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.

Ben Appleton

unread,
Aug 27, 2010, 1:26:36 AM8/27/10
to google-map...@googlegroups.com
On Fri, Aug 27, 2010 at 3:04 PM, Ben Appleton <appl...@google.com> wrote:


On Fri, Aug 27, 2010 at 2:53 PM, geoco...@gmail.com <geoco...@gmail.com> wrote:
On Aug 26, 9:26 pm, Ben Appleton <apple...@google.com> wrote:
> On Fri, Aug 27, 2010 at 2:17 PM, geocode...@gmail.com
> <geocode...@gmail.com>wrote:
>
> > On Aug 26, 7:49 pm, xf_aicn <xiaofan.zh...@asiainspection.com> 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?

Oh interesting: if the green line is the native geodesic then it appears slightly off compared to the red line.  At least one of them is wrong - I'll take a look.

Even more interesting: if you zoom in enough so that the 2 lines are distinct, then pan repeatedly (try the home/end/pgup/pgdn keys), the red line seems to wander away from the green line and then wander back again, meeting at regular intervals.  So they agree at a set of virtual vertices, and diverge elsewhere.

Your function geodesicPolyline() seems to compute 50 intermediate vertices, is that right?

geoco...@gmail.com

unread,
Aug 27, 2010, 2:31:51 AM8/27/10
to Google Maps JavaScript API v3
On Aug 26, 10:26 pm, Ben Appleton <apple...@google.com> wrote:
> On Fri, Aug 27, 2010 at 3:04 PM, Ben Appleton <apple...@google.com> wrote:
>
> > On Fri, Aug 27, 2010 at 2:53 PM, geocode...@gmail.com <
Yes. I hadn't notices the scalloping. But if I put markers on the
points that are calculated, that isn't where the lines line up...
v3_polyline_example_geodesic_proj.html

Using your suggestion fixes the mid-point on the normal polyline.

  -- 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
> >> > > google-map...@googlegroups.com.
> >> > > To unsubscribe from this group, send email to
> >> > > google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2B unsub...@googlegroups.com><google-maps-js-api-v3%2B

Ben Appleton

unread,
Aug 27, 2010, 3:21:14 AM8/27/10
to google-map...@googlegroups.com
Then it looks like I have oversimplified my geodesics.  I'll look into it.
 
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.

geoco...@gmail.com

unread,
Aug 27, 2010, 8:43:08 AM8/27/10
to Google Maps JavaScript API v3
On Aug 26, 10:12 pm, Ben Appleton <apple...@google.com> wrote:
> On Fri, Aug 27, 2010 at 2:59 PM, geocode...@gmail.com
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-js-a...@googlegroups.com<google-maps-js-api-v3%2B unsub...@googlegroups.com><google-maps-js-api-v3%2B

Ben Appleton

unread,
Aug 27, 2010, 1:00:30 PM8/27/10
to google-map...@googlegroups.com

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

> To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.

geoco...@gmail.com

unread,
Aug 27, 2010, 5:04:19 PM8/27/10
to Google Maps JavaScript API v3
On Aug 27, 10:00 am, Ben Appleton <apple...@google.com> wrote:
> 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.

Is there any other way to tell when it is loaded? This means if I
want to use the projection in the GetPoint(s)AtDistance function, I
have to do my map initialization in 2 steps:

1. initialize the map object in the body onload function
2. initialize any polylines, points or markers that depend on
GetPoint(s)AtDistance/the projection in another "projection" onload
function.

Is there some kind of a "map" onload event the will tell me when
everything is ready?

This is another instance where some things aren't available right
away, it has come up before with map.getBounds not being useful until
sometime after the map has been created:
http://groups.google.com/group/google-maps-js-api-v3/browse_frm/thread/563ed63c2bd60749/2fd92dd62b833afd?lnk=gst&q=getBounds#2fd92dd62b833afd

It seem like this could make for nasty dependencies. Is there a
general solution?

-- Larry

> 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
>
> >> > google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2B­unsub...@googlegroups.com><google-maps-js-api-v3%2B
>
> unsub...@googlegroups.com>>> > .
> >> > 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
>
> google-map...@googlegroups.com.> To unsubscribe from this group, send email to
>
> google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2B­unsub...@googlegroups.com>
> .> For more options, visit this group at
>
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>
>
>
> - Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Ben Appleton

unread,
Aug 29, 2010, 7:34:50 PM8/29/10
to google-map...@googlegroups.com
Confirmed, I had set too low a limit on the number of vertices.  I've fixed it locally, should go live in a week or so.

- Ben

Ben Appleton

unread,
Aug 29, 2010, 7:41:07 PM8/29/10
to google-map...@googlegroups.com
On Sat, Aug 28, 2010 at 7:04 AM, geoco...@gmail.com <geoco...@gmail.com> wrote:
On Aug 27, 10:00 am, Ben Appleton <apple...@google.com> wrote:
> 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.

Is there any other way to tell when it is loaded?  This means if I
want to use the projection in the GetPoint(s)AtDistance function, I
have to do my map initialization in 2 steps:

1. initialize the map object in the body onload function
2. initialize any polylines, points or markers that depend on
GetPoint(s)AtDistance/the projection in another "projection" onload
function.

True.  But since the midpoint depends on the projection, you have to handle changes to the projection regardless.
 
Is there some kind of a "map" onload event the will tell me when
everything is ready?

This is another instance where some things aren't available right
away, it has come up before with map.getBounds not being useful until
sometime after the map has been created:
http://groups.google.com/group/google-maps-js-api-v3/browse_frm/thread/563ed63c2bd60749/2fd92dd62b833afd?lnk=gst&q=getBounds#2fd92dd62b833afd

It seem like this could make for nasty dependencies.  Is there a
general solution?

In a sense there are 2 general solutions:
1 - If you have a function that depends on some properties, such as projection or bounds, you should re-evaluate that function when they change.
2 - If our API makes it tedious to do simple things, we should improve our API.
We have held off making the bounds synchronously available, as that depends on the projection, which depends on the maptype, which requires loading a bunch more code upfront.

To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.

geoco...@gmail.com

unread,
Aug 29, 2010, 7:44:01 PM8/29/10
to Google Maps JavaScript API v3
On Aug 29, 4:34 pm, Ben Appleton <apple...@google.com> wrote:
> Confirmed, I had set too low a limit on the number of vertices.  I've fixed
> it locally, should go live in a week or so.

Thank you.

-- Larry

>
> - Ben
>
> On Fri, Aug 27, 2010 at 5:21 PM, Ben Appleton <apple...@google.com> wrote:
>
> > On Fri, Aug 27, 2010 at 4:31 PM, geocode...@gmail.com <
> >> > >> google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2B unsub...@googlegroups.com><google-maps-js-api-v3%2B

geoco...@gmail.com

unread,
Aug 29, 2010, 8:04:43 PM8/29/10
to Google Maps JavaScript API v3
On Aug 29, 4:41 pm, Ben Appleton <apple...@google.com> wrote:
> On Sat, Aug 28, 2010 at 7:04 AM, geocode...@gmail.com
> <geocode...@gmail.com>wrote:
> > On Aug 27, 10:00 am, Ben Appleton <apple...@google.com> wrote:
> > > 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.
>
> > Is there any other way to tell when it is loaded?  This means if I
> > want to use the projection in the GetPoint(s)AtDistance function, I
> > have to do my map initialization in 2 steps:
>
> > 1. initialize the map object in the body onload function
> > 2. initialize any polylines, points or markers that depend on
> > GetPoint(s)AtDistance/the projection in another "projection" onload
> > function.
>
> True.  But since the midpoint depends on the projection, you have to handle
> changes to the projection regardless.
>
> > Is there some kind of a "map" onload event the will tell me when
> > everything is ready?
>
> > This is another instance where some things aren't available right
> > away, it has come up before with map.getBounds not being useful until
> > sometime after the map has been created:
>
> >http://groups.google.com/group/google-maps-js-api-v3/browse_frm/threa...
>
> > It seem like this could make for nasty dependencies.  Is there a
> > general solution?
>
> In a sense there are 2 general solutions:
> 1 - If you have a function that depends on some properties, such as
> projection or bounds, you should re-evaluate that function when they
> change.

The issue is that people want to create maps, put markers on them,
draw polylines,... and the way it is set up, a detailed understanding
of the underlying implementation is required (and at this point those
details don't seem to be described in the documentation, but maybe I
don't know where to look). How do we know what properties functions
depend on?

It doesn't just work, for something as simple as putting a marker on a
polyline in a way that will always work. I can use the "simple"
algorithm that doesn't depend on the projection, but that won't do the
right thing in all cases. If I use the correct algorithm, I can't use
it until after the map has completed initialization.


> 2 - If our API makes it tedious to do simple things, we should improve our
> API.
> We have held off making the bounds synchronously available, as that depends
> on the projection, which depends on the maptype, which requires loading a
> bunch more code upfront.

I don't know the right answer, I just know that the way it is
currently implemented is going to cause confusion. This is now the
version of the API you want "everyone" to use.

Is there an event available when the map has finished initializing
(everything is available)? That would make a 2-stage initialization
easier, create the map when the onload function runs, then add all the
contents when the "map ready" (or whatever) event fires.

Ben Appleton

unread,
Aug 29, 2010, 8:27:34 PM8/29/10
to google-map...@googlegroups.com

I mean simply that, if you refer to some property (such as projection)
when computing a value (such as a marker position), you probably want
to update the computation when the property changes.

> It doesn't just work, for something as simple as putting a marker on a
> polyline in a way that will always work.  I can use the "simple"
> algorithm that doesn't depend on the projection, but that won't do the
> right thing in all cases.  If I use the correct algorithm, I can't use
> it until after the map has completed initialization.

You can render your polys as geodesics, then they do not depend on the
projection. The problem here is that the API works with LatLngs as
much as possible (abstracting away the projection) but polys render as
rhumb lines as a fast default. Placing a marker in the middle of a
rhumb line depends on the projection, so you need to handle changes to
the projection.

>> 2 - If our API makes it tedious to do simple things, we should improve our
>> API.
>> We have held off making the bounds synchronously available, as that depends
>> on the projection, which depends on the maptype, which requires loading a
>> bunch more code upfront.
>
> I don't know the right answer, I just know that the way it is
> currently implemented is going to cause confusion.  This is now the
> version of the API you want "everyone" to use.

Yes it is.

> Is there an event available when the map has finished initializing
> (everything is available)?  That would make a 2-stage initialization
> easier, create the map when the onload function runs, then add all the
> contents when the "map ready" (or whatever) event fires.

If your code is going to be robust to property changes, such as
changes to the projection, you're going to have to listen for
'projection_changed' regardless. Once you make your code handle
property changes, you find you no longer care about "map ready",
because that is just another property change. So while a "map ready"
event might sound simpler, I'm concerned that it just hides the fact
that properties change, so your code will break when the user changes
eg. the map type.

> To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.

geoco...@gmail.com

unread,
Aug 29, 2010, 8:49:12 PM8/29/10
to Google Maps JavaScript API v3
On Aug 29, 5:27 pm, Ben Appleton <apple...@google.com> wrote:
> On Mon, Aug 30, 2010 at 10:04 AM, geocode...@gmail.com
I never change the map projection. I just use the standard map
types. But I am probably not the person that is going to have this
problem.

> Once you make your code handle
> property changes, you find you no longer care about "map ready",
> because that is just another property change.  So while a "map ready"
> event might sound simpler, I'm concerned that it just hides the fact
> that properties change, so your code will break when the user changes
> eg. the map type.

That may be true. But:
The example that put the marker in the middle of the normal polyline
requires me to wait for the projection loaded event. That wasn't
obvious. It required me to create the 2-stage initialization.
Examples where I want to load something based on bounds, require me to
wait for the bounds_changed event, how many of these different cases
will there be? I suspect it will get messy. The "map ready" event
would allow all of the second stage initialization to be done at once,
a simpler paradigm for those that don't want to understand all the
details (as I said above, I rarely, probably never, change the
projection on the map).

It seems like it will require a different mindset. I know you have a
"light is better" design goal for this API, which is worthy. Just
raising some food for thought and airing my concerns.
> >> > > >> > > >  geodesic_markers.PNG...
>
> read more »

Ben Appleton

unread,
Aug 29, 2010, 8:55:35 PM8/29/10
to google-map...@googlegroups.com

This is not a problem today, but in future there may be other map
types with different projections. If the user switches between them,
your polyline midpoint marker will appear to be in the wrong place.
This is probably not a terrible issue in your application though.

>> Once you make your code handle
>> property changes, you find you no longer care about "map ready",
>> because that is just another property change.  So while a "map ready"
>> event might sound simpler, I'm concerned that it just hides the fact
>> that properties change, so your code will break when the user changes
>> eg. the map type.
>
> That may be true.  But:
> The example that put the marker in the middle of the normal polyline
> requires me to wait for the projection loaded event.  That wasn't
> obvious.  It required me to create the 2-stage initialization.
> Examples where I want to load something based on bounds, require me to
> wait for the bounds_changed event, how many of these different cases
> will there be?  I suspect it will get messy.  The "map ready" event
> would allow all of the second stage initialization to be done at once,
> a simpler paradigm for those that don't want to understand all the
> details (as I said above, I rarely, probably never, change the
> projection on the map).
>
> It seems like it will require a different mindset.  I know you have a
> "light is better" design goal for this API, which is worthy.  Just
> raising some food for thought and airing my concerns.

Thanks - that the bounds is not immediately ready confuses a lot of
developers, which strongly suggests we should change the API. We're
thinking about how best to do this.

> To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.

geoco...@gmail.com

unread,
Aug 31, 2010, 3:59:56 AM8/31/10
to Google Maps JavaScript API v3
On Aug 29, 4:34 pm, Ben Appleton <apple...@google.com> wrote:
> Confirmed, I had set too low a limit on the number of vertices.  I've fixed
> it locally, should go live in a week or so.

Noticeable changes:
* Geodesics have been improved for higher zooms

Ben,
Looks much better, thank you.

-- Larry


>
> - Ben
>
> On Fri, Aug 27, 2010 at 5:21 PM, Ben Appleton <apple...@google.com> wrote:
>
> > On Fri, Aug 27, 2010 at 4:31 PM, geocode...@gmail.com <
> >> > >> google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2B unsub...@googlegroups.com><google-maps-js-api-v3%2B

Ben Appleton

unread,
Aug 31, 2010, 4:14:19 AM8/31/10
to google-map...@googlegroups.com

No worries!

Ben

> To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages