Categories
Actionscript Adobe Air Flash flex

Calculate and Set Bounds (Bounding Box) from Points in Google Maps Flash [Update]

I’ve got a list of points in my database, which I want to show neatly in a Google Maps Flash Map.

Thus, I …

  1. calculate the bounding box around these points
  2. calculate the center of this bounding box
  3. set the zoom level of the map in a way that the zoomed cutout contains all points
  4. set the center of the map
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//1.
var bounds:LatLngBounds = new LatLngBounds();
for each(var mapObject in tripMessages){
    var currentLatLon:LatLng = new LatLng(mapObject.latitude, 
	                                       mapObject.longitude);
    bounds.extend(currentLatLon);
}
 
//2.
var center:LatLng = bounds.getCenter();
 
//3.
map.setZoom(map.getBoundsZoomLevel(bounds));
 
//4.
map.setCenter(center);
Categories
Actionscript Flash Multi-Touch

Google Maps Multi-touch App

I’ve built a small Google Maps multi-touch app with Flex and Flash over the last days:

It uses the Google Maps Flash API and the TUIO Actionscript classes and the Touchlib from the Nuigroup.

The red stuff on the screen means that i am using the debug mode of Google Maps for Flash. That is because I execute the Flash file on my local computer. The problem is: For TUIO I need to connect to a local socket. Actually I don’t know how to access a local socket server with a Flash app that opens up in my browser on a remote site (and if this was possible it would scare the hell out of me). Seems like I need to live with the red stuff…

Maybe someone has wondered why I only use the view with satellite pictures. It is also possible to have the maps view but by the time I produced that video the maps servers were offline for a day.

Update: Google Maps Multi-touch Application Actionscript Code