results[0]; // focus on the resulots->locations portion of the data. $locations = $results->locations[0]; // determine if any of our coordinates meet any of the extreme conditions and reset extremes accordingly if ($locations->latLng->lat > $lat_max) $lat_max = $locations->latLng->lat; if ($locations->latLng->lat < $lat_min) $lat_min = $locations->latLng->lat; if ($locations->latLng->lng > $lng_max) $lng_max = $locations->latLng->lng; if ($locations->latLng->lng < $lng_min) $lng_min = $locations->latLng->lng; // add coordinate to positions array in a format that will play nicely with plotting later $positions[] = "lat:".$locations->latLng->lat . ", lng:" . $locations->latLng->lng; } // calculate the center latitude and longitude $center_lat = ($lat_min + $lat_max) / 2; $center_lng = ($lng_min + $lng_max) / 2; //specify our map dimensions and scale size in pixels define('MAP_WIDTH', '500'); define('MAP_HEIGHT', '400'); define('MAP_SCALE_IN_PIXELS', '77'); // This array contains the number of kilometers, the standard scale on mapquest contains at each zoom factor. $zoom_ranges = array(1840,630,210,71,32,14,7,3.2,1.6,0.8,0.4,0.2,0.1,0.05,0.03,0.02); // This is an implementation of the Haversine Formula that calculates distance in Kilometers between // ($lat1,$lon1) and ($lat2,$lon2). function calculate_distance_km ($lat1, $lon1, $lat2, $lon2) { return ( 3958*3.14159265*sqrt( ($lat2-$lat1) * ($lat2-$lat1) + cos($lat2/57.29578)*cos($lat1/57.29578)*($lon2-$lon1)*($lon2-$lon1))/180); } // calculate the change in X and Y coordinates separately $x_delta = calculate_distance_km($lat_min, $lng_min, $lat_max, $lng_min); $y_delta = calculate_distance_km($lat_min, $lng_min, $lat_min, $lng_max); // calculate the best zoom factor on the X-axis for ($bestX = 0; $bestX < sizeof($zoom_ranges) ; $bestX++) { // calculate the width of the total map in kilometers $total_width_km = MAP_WIDTH * $zoom_ranges[$bestX] / MAP_SCALE_IN_PIXELS; if ($total_width_km < $x_delta) break; } // calculate the best zoom factor on the Y-axis for ($bestY = 0; $bestY < sizeof($zoom_ranges); $bestY++) { // calculate the height of the total map in kilometers $total_height_km = MAP_HEIGHT * $zoom_ranges[$bestY] / MAP_SCALE_IN_PIXELS; if ($total_height_km < $y_delta) break; } // we want to take the minimum value, because we don't want to zoom in too far. $zoom_best = min($bestX, $bestY); ?>
'; foreach ($addresses as $fa) { if (isset($phones[$num]) && strlen($phones[$num]) > 0) { $fa .= ' — '. $phones[$num]; } $num++; echo '
  • '. $fa . '
  • '; } echo ''; ?>