Discussion Forums  >  Maps, Device Location, Tracking

Replies: 1    Views: 142

Rishav
Code is Art
Profile
Posts: 153
Reg: Jan 26, 2012
Dubai
8,780
05/26/12 07:50 PM (11 years ago)

Google Places API integration with Google Maps Plugin

Here is the code i created to convert google places api to buzztouch map compatible json.I know they provide json feed but i found converting xml easier for buzztouch. Thought this might be of great use for all. Just put in your api key and upload it to your server. Point the Data Url to this page with the variables and enjoy.. Hope you all like it. <?php header('Content-type: application/json'); $file= file_get_contents("https://maps.googleapis.com/maps/api/place/search/xml?" . "location=" . $_GET['location'] . "&radius=" . $_GET['radius'] . "&types=" . $_GET['types'] . "&sensor=false&key=yourkeyhere"); $file=str_replace('<?xml version="1.0" encoding="UTF-8"?>','',$file); $file=str_replace('<result>','{ "itemType":"BT_mapLocation", ',$file); $file=str_replace('</result>',' "loadScreenWithItemId":"showDirections" },',$file); $file=str_replace('<lat>','"latitude":"',$file); $file=str_replace('</lat>','",',$file); $file=str_replace('<id>','"itemId":"',$file); $file=str_replace('</id>','",',$file); $file=preg_replace('|<type>(.*?)</type>|is','',$file); $file=preg_replace('|<reference>(.*?)</reference>|is','',$file); $file=preg_replace('|<icon>(.*?)</icon>|is','',$file); $file=preg_replace('|<html_attribution>(.*?)</html_attribution>|is','',$file); $file=preg_replace('|<status>(.*?)</status>|is','',$file); $file=str_replace('<lng>','"longitude":"',$file); $file=str_replace('</lng>','",',$file); $file=str_replace('<name>','"title":"',$file); $file=str_replace('</name>','",',$file); $file=str_replace('<vicinity>','"subTitle":"',$file); $file=str_replace('</vicinity>','",',$file); $file=str_replace('<location>','',$file); $file=str_replace('</location>','',$file); $file=str_replace('<geometry>','',$file); $file=str_replace('</geometry>','',$file); $file=str_replace('<PlaceSearchResponse>','',$file); $file=str_replace('</PlaceSearchResponse','',$file); $file=str_replace('>','',$file); echo '{ "childItems":['; echo $file; echo ' ] }'; ?>
 
Fred@mySkylla com
Android Fan
Profile
Posts: 5259
Reg: Oct 03, 2011
location unknow...
62,560
like
05/26/12 08:04 PM (11 years ago)
Nice, i’ll add a link to my Buzztouch & Google Maps article pointing to this thread. Fred
 

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.