My favorites | Sign in
Project Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Licensed under the Apache License, Version 2.0 (the "License"):
* http://www.apache.org/licenses/LICENSE-2.0
*/
package com.google.maps.examples {
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.display.Shape;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import com.google.maps.MapEvent;
import com.google.maps.Map;
import com.google.maps.MapType;
import com.google.maps.LatLng;
import com.google.maps.LatLngBounds;
import com.google.maps.ProjectionBase;
import com.google.maps.controls.MapTypeControl;
import com.google.maps.controls.ZoomControl;
import com.google.maps.controls.PositionControl;
import com.google.maps.controls.ControlPosition;
import com.google.maps.controls.ControlBase;
import com.google.maps.interfaces.IMap;

public class TextualZoomControl extends ControlBase {

/**
* Constructor of custom control.
* @constructor.
* @param controlColour Colour transform applied to control's black buttons.
*/
public function TextualZoomControl() {
// Control will be placed at the top left corner of the map,
// 10 pixels from the edges.
super(new ControlPosition(ControlPosition.ANCHOR_TOP_LEFT, 7, 7));
}


public override function initControlWithMap(map:IMap):void {
createButton("Zoom in", 0, 0,
function(event:Event):void
{ map.zoomIn(); });
createButton("Zoom out", 0, 20,
function(event:Event):void
{ map.zoomOut(); });
}

private function createButton(text:String,
x:Number,
y:Number,
callback:Function):void {
var button:Sprite = new Sprite();
button.x = x;
button.y = y;

var label:TextField = new TextField();
label.text = text;
label.x = 2;
label.selectable = false;
label.autoSize = TextFieldAutoSize.CENTER;
var format:TextFormat = new TextFormat("Verdana");
label.setTextFormat(format);

var buttonWidth:Number = 100;
var background:Shape = new Shape();
background.graphics.beginFill(0xFFFFFF);
background.graphics.lineStyle(1, 0x000000);
background.graphics.drawRoundRect(0, 0, buttonWidth, 18, 4);

button.addChild(background);
button.addChild(label);
button.addEventListener(MouseEvent.CLICK, callback);

addChild(button);
}
}
}
Show details Hide details

Change log

r84 by pamela.fox on Jun 03, 2008   Diff
Updating TextualZoomControl to use new
function name initControlWithMap
Go to: 
Project members, sign in to write a code review

Older revisions

r8 by pamela.fox on May 13, 2008   Diff
Adding MapSimple example
r2 by pamela.fox on May 13, 2008   Diff
Adding first draft of examples for the
Maps API for Flash
All revisions of this file

File info

Size: 2587 bytes, 80 lines

File properties

svn:executable
*
Hosted by Google Code