Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Anyone else having problems with this component today (in the simulator)??? All of a sudden now I can't get it to show a map, even from a virgin download of the component + test app! ARGH!
 
I could figure that the problem not updating the center with Lat Lng is because of a javascript error.
At the
- (void) setCenterWithLatLng:(GLatLng)latlng
method on MapWebView change:

Code:
NSString *script = 
        [NSString stringWithFormat:
         @"var newCenterLatLng = map.fromContainerPixelToLatLng(newCenterPixel);"
          "map.setCenter(new GLatLng(%lf, %lf));", 
         latlng.lat, latlng.lng];


to :

Code:
NSString *script = 
		[NSString stringWithFormat:
		@"var newCenter;"
		 "if(newCenter==null || newCenter == 'undefined') { "
			"newCenter = new GLatLng(%lf, %lf); "
		 "}"
		 "map.setCenter(newCenter, 17);",
latlng.lat, latlng.lng];

and this should solve the problem.

The "17" parameter is the zoom level. :)

to add custom icons i'm using the same function because of my project needs. But is easy to create another function for this. The code is below:

<CODE>
NSString *script =
[NSString stringWithFormat:
@"var newCenter;"
"if(newCenter==null || newCenter == 'undefined') { "
"newCenter = new GLatLng(%lf, %lf); "
"}"
"map.setCenter(newCenter, 17);"

"var myIcon = new GIcon(G_DEFAULT_ICON);"
"myIcon.image = 'http://URL_OF_YOUR_CUSTOM_ICON/ICON.png';"
"myIcon.shadow = '';"

"myIcon.iconSize = new GSize(27, 31);"

"markerOptions = { icon:myIcon };"

"var marker = new GMarker(newCenter, markerOptions);"
"map.addOverlay(marker);",

latlng.lat, latlng.lng];
</CODE>

just change the URL to find the icon and the size of it and voila :)

You do things with javascript with this project , and I'm using it a lot.

Thanks a lot to the author.
 
Thanks for the center fix!

Yeah, I know how I can add A marker... thing is, I will be getting data from a data feed containing the positions of multiple items I need to place on the map. I'll be getting them one at a time, and they'll need to update position.

Now,I could certainly stuff those all into a data model, and whenever there's an update to teh data model, drop all the layers and create a whole new batch, but I'm going to be getting an update from each item every 5 seconds... 7 items, each refreshing all 7 every 5 seconds = a LOT of blinking! I really need a way to be able to tell the JS to MOVE the markers, and track which marker is which and only move that one...

Any ideas???

And I'm still having issues with the map showing up just as a white screen in the simulator. It was working fine when I tried it the other day, but now I can't even get a fresh download of the MapTest application to run. It just shows a white screen in the sim.
 
help in javascript of the map

Dear Mr Gammal,

Thanks a lot for such a wonderful post and sharing it. Looking at this code, I understand that in your website you have written a kind of plugin which fetches map from Google maps and modfies their javascript to somewhat and delivers to the client. i would be much grateful if you can share that part of the server side code, so that we can use this webview control freely. If not, at least some hints how to do those things will be much helpful if you can share with us.

regards
ch
 
Anyone experience very slow map load using this code? since the initial load is slow, I just decided to use google static map which loads 70% quicker then this... of course the downside is that no zoom, no panning, etc...

anyone have solutions for increasing speeD?
 
Dear Mr Gammal,

Thanks a lot for such a wonderful post and sharing it. Looking at this code, I understand that in your website you have written a kind of plugin which fetches map from Google maps and modfies their javascript to somewhat and delivers to the client. i would be much grateful if you can share that part of the server side code, so that we can use this webview control freely. If not, at least some hints how to do those things will be much helpful if you can share with us.

regards
ch

Actually, all you need to do is point your normal machines' browser to that URL, capture the source of the page that's returned, and host that HTML yourself (changing the Google Developer' key to your own...) That's all. There's no magic taking place on the server side...
 
Still did not get it !

But why am I not able to change Lat and Long for this demo mapview application ? If I casn where should I do ?

secondly, why is this demo application not directly fetching map from google map rather is fetching through weneae/iphone_test ?

I suspect there are changes in javascript which if shared can do a lot good for understanding this.

regards
ch
 
got it!

shame on me! :(

I figured out there are some rudimentary javascript written in wenear site, which i copied and pasted to a local file of my own and it worked !

But one thing I tried failed. I wanted to pass latitude and longitude parameter values.

NSString *filePath = [[NSBundle mainBundle] pathForResource:mad:"me1" ofType:mad:"html"];
filePath = [filePath stringByAppendingString:mad:"?latitude=21.786600&longitude=82.794762&zoom=10"];

NSLog(filePath);

NSURL *url = [NSURL fileURLWithPath:filePath];

[self loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:filePath]]];

I tried the above code. It did not work.

when i did NSLog([url parameterString]); it wrote a blank in the log.

why so ? If I can pass parameters to this html file properly, my problem will be solved. Please give ideas, I know it is html/javascript related, but ... stuck, unfortunately

regards
ch
 
fromLatLngToContainerPixel not working !

Now again, I need to display a marker at appropriate location of the map if it is visible. Say, if my map center lat lng is 27.7777 and 122.2222 respectively, I need to display an icon corresponding to lat lng 27.1111 and 122.1111

in this scenario I need to know current bounds of the map etc.

I tried using fromLatLngToContainerPixel

But this javascript function returns empty string. So location comes zero or garbage....

Please help if anybody have succeded

regards
Ch
 
no returning javascript functions working !

It seems the function moveby and pantocenter, these 2 functions are only working.

basically the function which should return a value through sscanf is not working. the string returns by evaljs is null.

even getCenterPixel getCenterLatLng are also not working. were these functions ever tested properly ?

please guys share your findings.

unless i find out the pixels and corresponding lat lng, how would i display and reposition on zoom, drag the overlays ?

regards
Ch
 
my goodness

Pardon me, I figured out that all those functions are working only when i call it after the whole map is loaded.

now i have a real problem before me. As soon as my aplication starts, i need to display maps with overlays. I cannot determine overlay positions at viewdidload function because mapview us still loading. How would i write a function which gets notified when map loading is finished ?

please help anybody ....

regards
Jagat
 
yes it is, they are called markers in the google maps slang. i am sure you will figure out how, the google maps api documentation is one of the best api documentations i ever saw. they have plenty of examples too.
 
yes it is, they are called markers in the google maps slang. i am sure you will figure out how, the google maps api documentation is one of the best api documentations i ever saw. they have plenty of examples too.

No we are not talking about the google map webpage here. The whole thread has been talking about the google map component, a library that you embed into your UIView. And I want to know if that component supports adding pin/marker.
 
No we are not talking about the google map webpage here. The whole thread has been talking about the google map component, a library that you embed into your UIView. And I want to know if that component supports adding pin/marker.

Yes, we are. The API is just a wrapper around a UIWebView. From the project's home page:

A component that you can add to your iPhone application to access all basic features of Google Maps (similar to Android's MapView). It uses a UIWebView in the background to load the HTML/Javascript version of Google Maps, and offers a set of Objective-C methods that mimic a subset of the original Javascript methods for controlling the map.
 
Sdk map with tab bar application

I am a newbie for iphone dev, so please forgive the basic nature of the questions.

The google map code provides the "launching" code for the map in the MapViewAppDelegate. However, I am creating an application that is a tab bar based app and want to launch the app when the tab is clicked. So I have two questions:

1) How would I modify the current launch code the map?
[tabBarController addSubView:mapView]; ?

2) Should I put the launch code in my MapViewController class in the loadView, didLoad, or initWithNibName class?


Thanks
 
mapNinja

Hi all

I wanted to share that my company has developed a framework that lets you plug in a nice, tiled map view into your native iPhone application. It's called mapNinja. You can literally have a full featured map experience in your app in a matter of a few lines of code. There is support for image and geometry overlays, text annotations and more. We also have out of box connectors for most popular map providers. Feel free to PM me for more info if you are interested, or check out our FB page for some more info:

http://www.facebook.com/pages/mapNinja/65460296809?ref=ts

Thanks
Chris
 
You guys are aware that you can't use Google Maps in an application that you charge for?

In fact, even using it in a Mobile application at all is dubious. See http://code.google.com/apis/maps/terms.html

Google HAS acted on this and can do at any time.

9.1 Free, Public Accessibility to Your Maps API Implementation. Your Maps API Implementation must be generally accessible to users without charge. You may require users to log in to your Maps API Implementation if you do not require users to pay a fee. Unless you have entered into a separate written agreement with Google or obtained Google's written permission, your Maps API Implementation must not:

(a) require a fee-based subscription or other fee-based restricted access; or
(b) operate only behind a firewall or only on an internal network (except during the development and testing phase).

10.8 use the Static Maps API other than in an implementation in a web browser;
 
You guys are aware that you can't use Google Maps in an application that you charge for?

In fact, even using it in a Mobile application at all is dubious. See http://code.google.com/apis/maps/terms.html

Google HAS acted on this and can do at any time.

Our mapNinja product provides out-of-box connectivity to Microsoft Virtual Earth maps, several open-source map providers, and our in-house map server. Depending on requirements there are a lot of cost effective ways to enable a killer maps experience within free or paid apps. It pains me to see so much time and effort being spent by people all trying to solve the same problem (nice in-app maps on the iphone) which is we we developed the mapNinja iPhone maps SDK.
 
Our mapNinja product provides out-of-box connectivity to Microsoft Virtual Earth maps, several open-source map providers, and our in-house map server. Depending on requirements there are a lot of cost effective ways to enable a killer maps experience within free or paid apps. It pains me to see so much time and effort being spent by people all trying to solve the same problem (nice in-app maps on the iphone) which is we we developed the mapNinja iPhone maps SDK.

Everyone is trying to solve the dame problem because non one refuse to share their work. And that includes you because mapninja requires you to show ads.
 
Everyone is trying to solve the dame problem because non one refuse to share their work. And that includes you because mapninja requires you to show ads.

For clarification: the mapNinja product is available for free, which requires ad display. Alternatively, it is available for a one-time fee, which does not require ad display. The price is a fraction of what it costs to develop and test such a component from scratch; we invested heavily in making a high quality and well documented SDK. The mapNinja has been used by tens of thousands of end customers in our own apps, which provides a level of maturity and stability within the product that is not achievable any other way.
 
For clarification: the mapNinja product is available for free, which requires ad display. Alternatively, it is available for a one-time fee, which does not require ad display. The price is a fraction of what it costs to develop and test such a component from scratch; we invested heavily in making a high quality and well documented SDK. The mapNinja has been used by tens of thousands of end customers in our own apps, which provides a level of maturity and stability within the product that is not achievable any other way.
You may want to tone down the commercial advertising, which is against forum rules, or you may find yourself getting reported.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.