Sunday, May 11, 2008

A Google Maps View for The iPhone

If you've been following the development of location based applications under Android and the iPhone you must have seen a lot of comparison charts showing the strengths and weaknesses of each SDK and mentioning the differences. Well, now you can cross one difference off that list! As this article mentions, the iPhone SDK lacks a programmable map component similar to the MapView on Android, but you don't need to worry about that anymore; at eSpace, we've written a similar one for the iPhone! This one simply loads http://maps.google.com in a UIWebView which is displayed under a custom transparent UIView that receives touch events and translates them to Javascript Maps API calls. The source is available under the BSD license. If have questions, or if you want to merge in any cool updates, the project has a Google group at iphone-map-view@googlegroups.com. Here's a video demo of the thing in action:



12 comments:

dominic said...

Great work thus far!! Will there be the ability to add 'clickable' markers to the maps? I've added markers, but can't make them active.

Mahmoud AlGammal said...

Well, that feature is not on my radar currently, but you're welcome to add it! Almost everyone who contacted me regarding this MapView has been talking about implementing that feature in particular, so you'd be doing everyone a favor. It should be easy to implement, so if you're facing any problems we can discuss the details together.

karthikj said...

Hi,

Thanks, I got the code, but i have one doubt, is this code run on both simulator and device? i have execute the code using simulator but it only shows empty window, pls tell me how can i use this code effectively?

Thanks with,
Karthik

Brian said...

I got the latest code, but don't see any support for clickable markers. Is this being worked on?

Brian said...

having the same problem as karthik...just get an empty screen when running the xcode project. I created an issue on the google code site....please fix:)

Mahmoud AlGammal said...

The component loads this page http://www.wenear.com/iphone when it's added to its parent. The server was taken down for a short period earlier today, but it's up again at the time of this writing. If you wish, you can host the page anywhere else and load it from there.

As for clickable markers, I'm working on some modifications that will allow you to subclass the MapView and add markers as subviews. A delegate protocol will also exist so that the MapView subclass can receive notifications whenever the markers should be redrawn.

Brian said...

ahh...great it works now. Thanks for the quick response.

Anonymous said...

It would be great if you (or someone who is also using the classes) could add some more samples. I've played a bit with the classes, but so far wasn't able to center the map to a certain position, display a marker or modify the map for non-fullscreen display (for use in a tab-bar application)

Pepe Iborra said...

Some sort of caching is a must too for this kind of control. Have you considered that? Could a user of the library plug in and provide some sort of caching mechanism ?

testI said...

i was trying to develop an application using your mapview but i needs to add some another methods for that class like adding a marker or drawing a static path , like these features presented at
http://code.google.com/apis/maps/documentation/staticmaps/
i noticed your JavaScript snippet in the code , something like map.setZoom(%d);
so i wants to know how your map view is supposed to work with that params also is it possible to add the features that i want to add easily to your map view or i have to customize my own map
any way , i hope to hear from you as soon as possible

bearbully said...

Hi,
Great work. Very useful. Do you have the modifications for the clickable markers working ?

ahmdalitaha said...

is it normal when i use the MapView in the iphone to always load in certain GPS location (37.4419,-122.1419)??
that is fine by me but the problem is when i set the center to another GPS location , the map still in it's current location (37.4419,-122.1419) till i make a touch to move it manually"any direction", then the map goes to the correct location after that!!!!!