Grid overlay on to map

19,901 views
Skip to first unread message

tezz

unread,
Jan 26, 2012, 4:28:45 AM1/26/12
to Google Maps JavaScript API v3
Do someone have an example of a custom grid overlay for v3? I'm
trying
to develop one with autoscale based on current zoom level (just a
simple function with zoom_level as input and several 'if-else') and
min interval (on max zoom level) between grid lines as 1 minute. I
found one pretty example from Bill Chadwick for v2 and tried to
redesign it to use v3, but it doesn't work by some reason. The main
thing as I can see is that the execution doesn't go into 'draw' of my
custom overlay.

Hi,
Im a newbie trying to overlay a grid onto map. I'm trying
to develop one with autoscale based on current zoom level and
min interval (on max zoom level) between grid lines as 1 minute.
I did lot of reading on the web, but couldn't find a solution. Can
anyone
please give a some buz words here, which might help me complete my
work.
It would be a great help
Thank you.

Chris Broadfoot

unread,
Jan 26, 2012, 5:44:44 PM1/26/12
to google-map...@googlegroups.com
Hi tezz,

Try here as a starting point: 

Cheers
Chris

--
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.


geoco...@gmail.com

unread,
Jan 26, 2012, 6:50:38 PM1/26/12
to Google Maps JavaScript API v3
On Jan 26, 2:44 pm, Chris Broadfoot <c...@google.com> wrote:
> Hi tezz,
>
> Try here as a starting point:http://code.google.com/apis/maps/documentation/javascript/examples/ov...

This might help also:
http://www.geocodezip.com/v3_MW_example_eshapes.html

-- Larry

teja

unread,
Jan 26, 2012, 9:09:06 PM1/26/12
to google-map...@googlegroups.com
Hello Chris and geocodezip,
Thanks for the inputs.
I'm wondering if I draw a grid, using polygons, doesn't that degrade the performance? 
Everytime I zoom out I need to redraw, with more lines.
But if I try to overlay say  coloured images, I need to have different images to display at different levels.
How do I generate all those images?
My current work deals with overlaying some data on a state in US. The granularity of grid is 1 minute latitude,longitude.
Please give some suggestions.


Thank you,
tezz.
--
Tejaswi Kumar |  5154220202
Masters (Computer Science)
North Carolina State University.





Joseph Elfelt

unread,
Jan 27, 2012, 10:36:40 AM1/27/12
to Google Maps JavaScript API v3
In broad strokes, another possible approach for a grid is to:
1. Detect the bounds
2. Establish a larger 'viewport'
3. Build the grid with polylines (MVC array) that cover the larger
viewport.
4. Listen for a change in the map center and rebuild the grid
5. Consider changing grid scale based on zoom

If you are not required to use polygons to build the grid, then
polylines might be a better approach.

You can judge performance:
http://www.mappingsupport.com/p/gmap4.php?ll=39.626861,-104.942131&t=t1&z=10&coord=utm

teja

unread,
Jan 27, 2012, 11:18:52 AM1/27/12
to google-map...@googlegroups.com
Hello Joseph,
Thats a very good suggestion. Thank you.
But each box in my grid needs to filled by a color. That color depends upon the center of each grid box.
Is there any software which takes tiles at higher zoom level(i.e higher resolution) and gives tiles for other zoom levels?


--
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.

Joseph Elfelt

unread,
Jan 27, 2012, 11:29:04 AM1/27/12
to Google Maps JavaScript API v3
Sorry, I don't know the answer to your question about tiles.

I would still be tempted to address your task by
1. Build polyline grid
2. Analyze the polylines to build 4 corners for each grid box
3. Build polygons using the 4 grid box corners
4. Use API geometry library to get center of each grid box ( project
50% of the way between opposite corners)
5. Color the grid box polygon based on grid box center

teja

unread,
Jan 27, 2012, 11:55:54 AM1/27/12
to google-map...@googlegroups.com
I will try this...but Im still a bit worried about the number of polygons i would need to render when Im at the lowest zoom level.
Each of my polgon has 1 minute difference in lat and lon. So at the highest zoom I would need to draw around 60(lat minutes)*60(long minutes)*100(degrees I cover on the whole)...360000 polygons :D
Please let me know if you did kindof thing anytime.

Thank you
--
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.

Martin™

unread,
Jan 27, 2012, 1:24:25 PM1/27/12
to Google Maps JavaScript API v3
If performance is important then i'm sure you'll find a custom overlay
map type to be better than client side polyline or polygon rendering.

Here's the reference page:

http://code.google.com/apis/maps/documentation/javascript/maptypes.html#OverlayMapTypes

I daresay that creating a PHP script that uses gdlibrary to generate
and cache tiles would be the best approach.

www.google.co.uk/search?q=php+gd+library

Martin.


On Jan 27, 4:55 pm, teja <tejasu...@gmail.com> wrote:
> I will try this...but Im still a bit worried about the number of polygons i
> would need to render when Im at the lowest zoom level.
> Each of my polgon has 1 minute difference in lat and lon. So at the highest
> zoom I would need to draw around 60(lat minutes)*60(long
> minutes)*100(degrees I cover on the whole)...360000 polygons :D
> Please let me know if you did kindof thing anytime.
>
> Thank you

Joseph Elfelt

unread,
Jan 27, 2012, 6:00:03 PM1/27/12
to Google Maps JavaScript API v3
I like Martin's idea.
And, no, I have not generated anywhere near the number of polygons you
are talking about.

teja

unread,
Jan 27, 2012, 6:24:27 PM1/27/12
to google-map...@googlegroups.com

Thanks for your ideas guys.
I very much appreciate thhem.
this forum is a life saviour for me

Fabrizio Bartolomucci

unread,
Jun 7, 2012, 12:40:23 PM6/7/12
to google-map...@googlegroups.com
Yes, I did. I used the Directions library from Google and a decoder in php to extract the coordinated from the encoded gibberish.
Thanks anyway,
Fabrizio

Il giorno 04/giu/2012, alle ore 18:07, Benoit Vachon ha scritto:

Have you found a solution?  I developed the exact same thing using a custom map type (no polylines) and it eliminates all performance issues.


On Friday, 27 January 2012 18:24:27 UTC-5, teja wrote:

Thanks for your ideas guys.
I very much appreciate thhem.
this forum is a life saviour for me

On Jan 27, 2012 6:00 PM, "Joseph Elfelt" <joseph...@gmail.com> wrote:
I like Martin's idea.
And, no, I have not generated anywhere near the number of polygons you
are talking about.

--
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-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-api-v3+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.

Barry Hunter

unread,
Jun 7, 2012, 1:09:10 PM6/7/12
to google-map...@googlegroups.com
Probably a big late for this thread, but Bill has ported his grids to v3...
http://www.bdcc.co.uk/Gmaps/ll_grat_v3_demo.htm

More...
http://www.bdcc.co.uk/Gmaps/BdccGmapBits.htm
> --
> You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
Reply all
Reply to author
Forward
0 new messages