benji87 Posted January 14, 2008 Share Posted January 14, 2008 Hi all ive created a script that inserts post codes from a database into a geocoder that then pinpoints the locations on the google maps api. Trouble is that it can be really slow. As i guess it has to process each postcode seperatly from another URL. What i want to know is there any way for me to speed this process up as at the moment for about 10 records to be processed it takes around 13secs which will probably put any user off instantly! Here is my code: <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAVB6_Pid5otsy8EjejpFSmBR3B9hOBASpmCh0hnUHdY3zy_OoFxQY7sAWvr8MPMRYjIZWvTGByQJU3g" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ function load() { if (GBrowserIsCompatible()) { function createMarker(point,html) { var marker = new GMarker(point); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); return marker; } var map = new GMap2(document.getElementById("map")); map.setCenter(new GLatLng(50.8040, -1.0700), 13); map.addControl(new GLargeMapControl()); $i=0; while ($i < $num) { $event=mysql_result($result,$i,"event"); $postcode=mysql_result($result,$i,"postcode"); $email=mysql_result($result,$i,"email"); $phone=mysql_result($result,$i,"phone"); ?> <? $url = "http://geo.localsearchmaps.com/?zip="; $url .= urlencode($postcode); $url .= "&country=UK&use=google2&format=txt"; if ($grab_coordinates = file_get_contents($url)) { $coord_pair = explode(", ", $grab_coordinates); if (sizeof($coord_pair) == 2) { $latitude = $coord_pair[0]; $longitude = $coord_pair[1]; }; }; ?> <? echo "var point = new GLatLng($latitude,$longitude); var marker = createMarker(point,'<div style=\"width:240px; padding:4px; font-family:Lucida Sans, Arial;\">$event</br>$postcode</br>Email: $email</br>Telephone: $phone</div>') map.addOverlay(marker);" ?> <? $i++; } mysql_close(); ?> thanks } } //]]> </script> Quote Link to comment https://forums.phpfreaks.com/topic/85933-speeding-up-responce-time/ Share on other sites More sharing options...
tinker Posted January 14, 2008 Share Posted January 14, 2008 I'd say it's a connection / response issue with goggle, but they probably know that! I'm not sure if this is happening client side or server side, either way you could try threads to connect in parallel rather than series. I thought there was some support for threads in php but finding any ref's at mo, you could always run them through the system dumping the output and parsing that, however it seems there is support for javascript so you could use ajax...(oops this may depend upon browser design...) Quote Link to comment https://forums.phpfreaks.com/topic/85933-speeding-up-responce-time/#findComment-438789 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.