The attached patch makes it possible to display 'polygon', 'rpolygon' and 'circle' shapes on the map again.

There are 2 problems remaining the 'rpolygon' and 'circle' shapes:
- the circles aren't really round, there's probably the earth-flattening missing in the calculation
- 'rpolygon' shapes have (more or less) the right radius, but the starting angle isn't taken from the 2nd point, but always set to 0

polygon-path with coordinates work fine, I'd appreciate fixes for or help with the other 2 issues.

Comments?

Comments

ray007’s picture

Title: shape overlays » drawing lines and polygons on gmaps
StatusFileSize
new9.42 KB

A new patch with some fixes.
If possible we now use GPolyline instead of GPolygon and break up the lines into multiple segments, since the Google line drawing algorithm seems to have a problem with lines with many points when zooming in.

I'd really appreciate some feedback on my patches, or am I the only one trying to draw some routes on gmaps?

ray007’s picture

StatusFileSize
new8.74 KB

A bit more google-research and I found out, that the caller is expected to make sure all parameters are really numbers and not strings.
If we do that, there's no need to split up the lines ...

Ignore patch #2, take this one ;-)

ray007’s picture

StatusFileSize
new9.79 KB

stupid IE once again requires extra work, here a new patch to draw shapes in internet explorer too.
Be sure to have a look at the README.txt too ...

ray007’s picture

StatusFileSize
new7.19 KB

all right, updating this patch worked automatically, here it is again ;-)

I'd also recommend maybe making 1 commit to the whole project just killing all trailing whitespace ...

bdragon’s picture

Status: Needs review » Postponed (maintainer needs more info)

Slightly modified version committed. (Can't load on event markersready -- user may have shapes but no markers...)

Tested it a bit, it seems to draw lines at least.

Does this work OK?

Can I get some test macros?

ray007’s picture

Haven't yet tried your new release, but the macro I used to test my patch with is:

[gmap zoom=11 |center=49.29176955717864,-123.13751220703125 |width=700px |height=550px |id=map |control=Small |type=Map| markers=numbers::49.273964893181876,-123.16068649291992:Kits Pool + 49.29658355065509,-123.15399169921875:Second Beach Pool + 49.28964229401579,-123.0355453491211:New Brighton Pool|markers=blue::49.27721276406079,-123.13631057739258:Vancouver Aquatic Centre |line=#0000bb/2/1/4,4/Seabus:49.28695509355089,-123.10884475708008 + 49.310015464362806,-123.08464050292969| polygon=49.273124891768525,-123.24952125549316 + 49.268084582896336,-123.25973510742187 + 49.26433201857972,-123.2607650756836 + 49.26298774701013,-123.25836181640625 + 49.26192350604598,-123.25836181640625 + 49.26108329959868,-123.25716018676758 + 49.26013104833168,-123.25613021850586 + 49.25951487595601,-123.25484275817871 + 49.25873064544246,-123.25441360473633 + 49.25727418428457,-123.25389862060547 + 49.25688205278321,-123.25312614440918 + 49.25620982010423,-123.25201034545898 + 49.255257474803116,-123.25055122375488 + 49.252008158428836,-123.24668884277344 + 49.255985740509985,-123.23673248291015 + 49.25817047316041,-123.22969436645508 + 49.265508226162716,-123.23587417602539 + 49.2644440395575,-123.24282646179199 + 49.26825260148869,-123.2472038269043 + 49.27323689278344,-123.24857711791992|circle=#ff0000/3/1/#00ff00/0.3:49.29426915204543,-123.14008422851562+1| rpolygon=49.19426915204543,-123.18008422851562 + 49.22,-123.19 + 7]

including gpx-support also makes it rather easy to get some drawing on the map ...

and when we're at the shapes now: anybody got an idea why the circles aren't round?

bdragon’s picture

The circles are not round because they are representing a constant distance from a central point.

Since the earth is round, it cannot be represented completely accurately on a flat plane. So we use a projection to draw it. All projections have tradeoffs.

Google uses the Mercator projection, a cylindrical map projection. Circles appear flattened because of

See http://en.wikipedia.org/wiki/Mercator_projection for more details.

bdragon’s picture

(note to self, proofread first...)

It's possible that the circles ARE being drawn wrong, but I would put it down to projection distortion.

Try zooming way in on the equator and drawing a circle there. It should be nearly round.

Dewi Morgan’s picture

Definitely not projection distortion. After some testing, I see that the shape of the circle depends on the google map's window shape: if you have it wider than it is tall, your circles will be squashed vertically; if the view is square, the circles will be round; if the view is tall, then your circles will be stretched proportionately taller too.

So until that's fixed, use square views if you want round circles. Not possible for me, since our ward is not square http://stleonardsward.org.uk/ward_map (not a gmap map, and won't be, until I get lines working)

In my "Build a Gmap Macro" page, I have three "Click map" options - "Points" and "Circles" work fine, but "Lines" does nothing. Using ray007's example macro above I only see the circle, not either of the lines - any idea what I'm missing?

So far, I've just downloaded the 2007-May-06 version from http://ftp.osuosl.org/pub/drupal/files/projects/gmap-5.x-1.x-dev.tar.gz and untarred it over my existing system, checked if there were any DB updates (there were none), and tried to draw lines. What did I miss out? Do I need this "xmaps" thing mentioned on http://www.webgeer.com/gmapdemo ?

Dewi Morgan’s picture

OK, I'm definitely wrong about it being the shape of the window :) What I'm actually seeing is that in creating a page with a gmap filter and using the example code above, I see a vertically-squashed circle.

But in the "build a macro" page, at the same coordinates and zoom level, any circle I draw is vertically stretched. Zooming out to view the whole world, the vertically-stretched circles are taller near the poles, circular at the equator. Goes nuts if your circle points go either side of the date line.

Still can't draw real lines :(

ray007’s picture

circles and rpolygons are special cases of lines.
I had a problem with FF2 on windows, where I couldn't see the lines with google-default style. FF2 on linux had no problems there, but ... maybe try to define a linestyle for the polygon ?

Carlos Miranda Levy’s picture

Do note that this patch does not work with the latest release Dated May 6, 2007.
:(

bdragon’s picture

Status: Postponed (maintainer needs more info) » Fixed

I'm pretty sure all the bugs on this are gone.

Anonymous’s picture

Status: Fixed » Closed (fixed)
aren cambre’s picture