Discussion Forums  >  Maps, Device Location, Tracking

Replies: 2    Views: 133

mycapoeira
Aspiring developer
Profile
Posts: 3
Reg: Jul 19, 2012
Miami
5,130
11/23/12 09:35 PM (11 years ago)

Any way to pass a map pin location to a custom URL

I assume when a user clicks on a map pin it sends the coordinates to the map app for driving directions. any way I can send these coordinates to my custom url? My pins are created dynamically with php as a json. Or alternatively could I pass the URL through json? Thanks for any help.
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
11/25/12 01:56 AM (11 years ago)
Any of all of this is possible. It's a matter of figuring out the best approach. Because you're already creating the map locations dynamically, with PHP, I'm thinking... 1) Replace the loadScreenWithItemId value in your JSON to something else. Like: "loadURL" and set the value to something like mysite.com/details.php?latitude=22.22&longitude=-101.22" This should be easy because you're already outputting the location data using .PHP 2) Open BT_screen_map.m (same idea in Android) and find the "calloutButtonTapped" method starting on line 585. This is the method that runs if you tap the icon in the callout bubble. 3) Modify this method. The idea is that you won't be loading a "screen with an id" but instead creating a screen object dynamically in code. This will allow you to launch the Custom URL plugin with the URL you created in the JSON (different for each location). Something like this... //line 585 -(void)calloutButtonTapped:(id)sender{ //get the URL to load from the JSON for this location... NSString *loadURL = [BT_strings getJsonPropertyValue:tappedLocation.jsonVars:@"loadURL":@""]; //you could easily launch Safari with that URL...or...create a dynamic screen to load a plugin... //create the JSON for the next screen (the Custom URL screen in this case)... NSString *tmpJSON = [NSString stringWithFormat:@"{\"itemId\": \"na\",\"itemType\": \"BT_screen_customURL\", \"dataURL\":\"%@\"}", loadURL]; NSDictionary *tmpDictionary = [tmpJSON JSONValue]; //of course you could add as many properties to this JSON as you want for the Custom URL plugin....be sure to include the backslashes around the quotes (called escaping the quotes)... //Next, create a BT_item representing the next screen... BT_item *tmpScreen = [[BT_item alloc] init]; tmpScreen.itemId = @"NA"; tmpScreen.itemType = @"NA"; tmpScreen.jsonVars = tmpDictionary; //use the built in method to load the next screen.... [BT_viewControllerManager handleTapToLoadScreen:self.screenData:nil:tmpScreen]; //release memory for your the temporary screen you created... [tmpScreen release]; } You should be able to copy-paste that method and it should work without changing anything. I didn't check the syntax but it should work as is (assuming you add a loadURL to each of your locations). Like I said, there are tons of ways to do this, this is only. one. Good luck.
 
mycapoeira
Aspiring developer
Profile
Posts: 3
Reg: Jul 19, 2012
Miami
5,130
like
11/25/12 10:14 AM (11 years ago)
Thanks a million! I had gotten around it by dynamically loading a screen for each possible map location, but these ideas seem much better. In fact you've given me some other ideas to make the app better.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.