We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › Google Maps and Processing
Pages: 1 2 
Google Maps and Processing? (Read 11830 times)
Google Maps and Processing?
Feb 13th, 2008, 5:50pm
 
Hey guys, I'm working on a Processing map application and I started thinking "how cool would it be to pull images from google maps into processing?" I've toyed around with Walter Rafelsberger's WorldWindTest (http://www.metaportaldermedienpolemik.net/processing.org/worldwind/), but I'm not sure fast enough yet for my use.

My initial goal is to simply take addresses (or coordinates etc) and fly around visiting them. I realize I could just write a javascript google map to do this, but I'd like to integrate it with a larger Processing system.

Anyone have any thoughts on what direction to start looking to do this? It will be primarily rendered from a local machine so I'm even willing to embed a java-based browser in my Processing app if thats the direction I need to take it.
Re: Google Maps and Processing?
Reply #1 - Feb 13th, 2008, 8:32pm
 
If you're a fairly experienced Programmer, you might have some luck browsing the Actionscript 3 source of our Modest Maps library at http://modestmaps.com

It would be a great thing to port to Processing, and we've thought about it a few times here at Stamen. We haven't taken the plunge because it currently relies quite heavily on the Flash way of doing things and might not translate so easily to Processing.  We're also tempted to do a re-write of a lot of the tile handling code to use matrices in Flash, and that would definitely be the way to go in Processing.

Still, the Coordinate and Location classes as well as the map provider and projection/translation classes should port over fairly easily.

3D would be an exercise for the reader Smiley
Re: Google Maps and Processing?
Reply #2 - Feb 13th, 2008, 8:33pm
 
Actually now that I think about it, the Python code might also be worth a look - it doesn't deal with interactive maps but it will find and position map tiles in the correct place for you.
Re: Google Maps and Processing?
Reply #3 - Feb 19th, 2008, 7:34am
 
Since I last posted I've been porting Modest Maps to Processing.  If you're interested you can download a test version here:

http://www.tom-carden.co.uk/2008/02/18/modest-maps-vs-processing/
Re: Google Maps and Processing?
Reply #4 - Aug 2nd, 2008, 9:39am
 
I just downloaded the modest maps port and it works great! I also have a GPS module that I am reading through the serial port.

How can I change the center of the map using coordinates from the NMEA string (I've already parsed) instead of through clicking and dragging the mouse?
Re: Google Maps and Processing?
Reply #5 - Nov 11th, 2008, 10:37pm
 
tom,

thanks for sharing the library I have downloaded it and run it without any problems. However I have question.
I couldn't find the function to plot point on the map.

Has been implemented and if yes what is it and how do you use it?
Re: Google Maps and Processing?
Reply #6 - Nov 12th, 2008, 8:29am
 
Glad to hear it's working out.

To figure out where on screen you should be drawing, use map.locationPoint to turn a latitude and longitude location into an x,y point for drawing. You draw things the same way you would with regular Processing:

Location location = new Location(51.500, -0.126);
Point2f p = map.locationPoint(location);
fill(0,255,128);
stroke(255,255,0);
ellipse(p.x, p.y, 10, 10);

You can see this code commented out in the modestmaps_interactive sketch in the Modest Maps source repository: http://modestmaps.mapstraction.com/trac/browser/trunk/processing/sketches/modest_maps_interactive/modest_maps_interactive.pde
Re: Google Maps and Processing?
Reply #7 - Nov 12th, 2008, 9:17am
 
hi tom!

seems modestmaps is broken due to recent changes in PMatrix in the latest releases (154+) .. i get:


Exception in thread "Animation Thread" java.lang.InstantiationError: processing.core.PMatrix
at com.modestmaps.InteractiveMap.pointLocation(InteractiveMap.java:343)
at modest_maps_interactive.draw(modest_maps_interactive.java:124)
at processing.core.PApplet.handleDraw(PApplet.java:1394)
at processing.core.PApplet.run(PApplet.java:1299)
at java.lang.Thread.run(Thread.java:613)
Re: Google Maps and Processing?
Reply #8 - Nov 12th, 2008, 4:43pm
 
Oh, yay!
Re: Google Maps and Processing?
Reply #9 - Nov 12th, 2008, 5:27pm
 
tom,

Thanks for the reply. I actually did manage to find the function. Just forgot to share my findings. When using eclipse you can expose the API which is included in the jar which is ideal.

I am also getting an error which is sligtly different from the one fjen found. Saying that I am using the core.jar from version 0135

Here is the error I get:

Exception in thread "Thread-4" java.lang.OutOfMemoryError: Java heap space
       at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:41)
       at java.awt.image.Raster.createPackedRaster(Raster.java:458)
       at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.
java:1015)
       at java.awt.image.BufferedImage.<init>(BufferedImage.java:317)
       at processing.core.PGraphicsJava2D$ImageCache.update(PGraphicsJava2D.java:691)
       at processing.core.PGraphicsJava2D.imageImpl(PGraphicsJava2D.java:650)
       at processing.core.PGraphics.image(PGraphics.java:2151)
       at processing.core.PGraphics.image(PGraphics.java:2132)
       at processing.core.PApplet.image(PApplet.java:7580)
       at com.modestmaps.InteractiveMap.draw(InteractiveMap.java:213)
       at Main.draw(Main.java:165)
       at processing.core.PApplet.handleDisplay(PApplet.java:1465)
       at processing.core.PGraphics.requestDisplay(PGraphics.java:690)
       at processing.core.PApplet.run(PApplet.java:1562)
       at java.lang.Thread.run(Thread.java:613)


This happens after the 6th click on the zoom (+) button. It seems the debugging environment runs out of memory. I exported the app and everything is fine. Does anyone know what I could do to avoid that?

Re: Google Maps and Processing?
Reply #10 - Nov 12th, 2008, 7:02pm
 
If you're running out of memory you can try two things:

1. change map.MAX_IMAGES_TO_KEEP (an int) to a smaller number (the default is 256 which would be 64 MB of images)
2. increase the memory available to Processing in the preference pane

The latter will give a better map browsing experience, so long as you have the RAM to handle it.
Re: Google Maps and Processing?
Reply #11 - Nov 12th, 2008, 7:52pm
 
There's an updated sketch and jar file here: http://www.tom-carden.co.uk/wp-content/uploads/2008/11/modest_maps_interactive.zip

That should solve the PMatrix issue, I've tested with Processing 0154 successfully.
Re: Google Maps and Processing?
Reply #12 - Jan 18th, 2010, 1:11pm
 
Thanks so much Tom.  This is really working wonders for a project I've been working on for some time now.  Had built all the trig to map lat/lon coordinates and even pulled border data from US census bureau... but this is so much better.  

A couple of questions:
1. I'm primarily using the microsoft maps, and was wondering if its possible to include/exclude certain features.  The census bureau has congressional district borders, which I could continue to use separate from modest maps.  But, it would be very ideal if this could be party of a hybrid map.
2. Can you overlay items so that say, something I'm drawing in processing is on top of the aerial map yet below the borders of the states/countries?  This ties into question 1 somewhat. I have power plants that are being represented in various ways, and it helps to have the borders on top of the plants, particularly where the plant objects cluster up.

Also, I've seen the microsoft 3d maps and was thinking there might be a way to load that, or wrap the current map in processing around a sphere.  I had tried to do this in processing already with a single image of the earth, but this is clearly much better.

Lastly, how should I identify copywritten information in my code?  I want to give credit where due, and need to know how I should reference what you have provided.

Thanks again for posting this.  What a great resource!
Re: Google Maps and Processing?
Reply #13 - Jan 18th, 2010, 1:11pm
 
Thanks so much Tom.  This is really working wonders for a project I've been working on for some time now.  Had built all the trig to map lat/lon coordinates and even pulled border data from US census bureau... but this is so much better.  

A couple of questions:
1. I'm primarily using the microsoft maps, and was wondering if its possible to include/exclude certain features.  The census bureau has congressional district borders, which I could continue to use separate from modest maps.  But, it would be very ideal if this could be party of a hybrid map.
2. Can you overlay items so that say, something I'm drawing in processing is on top of the aerial map yet below the borders of the states/countries?  This ties into question 1 somewhat. I have power plants that are being represented in various ways, and it helps to have the borders on top of the plants, particularly where the plant objects cluster up.

Also, I've seen the microsoft 3d maps and was thinking there might be a way to load that, or wrap the current map in processing around a sphere.  I had tried to do this in processing already with a single image of the earth, but this is clearly much better.

Lastly, how should I identify copywritten information in my code?  I want to give credit where due, and need to know how I should reference what you have provided.

Thanks again for posting this.  What a great resource!
Re: Google Maps and Processing?
Reply #14 - Jan 27th, 2010, 9:56am
 
Hi Tom!

This seems like excellent library (although, I didn't try it yet...). You mentioned that there is no real permission from Google/MS/Yahoo to use those maps... maybe you could add open street maps as one possibility - that would be free for all use (I think).
Pages: 1 2