반응형
Flex를 사용하여 지도를 표시하는 프로젝트 중에 지도기능은 그대로 살리고 지도는 없애야 하는 상황이 생겼습니다. 구글맵을 이용하는데 타일만 사용하고 지도만 없애기가 되더군요.. 아래는 소스입니다. googlemap 지도타일 없애기...
CustomTileLayer.as 파일입니다. CustomTileLayer.as
1 2 3 4 5 6 7 8 9 10 11 12 13 | public function onMapReady(event:Event): void { this .setCenter( new LatLng( 35.51061174942211 , 127.0469068145752 ), 8 ); var normalMapType:IMapType = MapType.NORMAL_MAP_TYPE; var tileLayers: Array = normalMapType.getTileLayers().concat([]); tileLayers.push( new CustomTileLayer(normalMapType.getTileSize())); var customMapType:IMapType = new MapType(tileLayers,normalMapType.getProjection(), "White" ); mc.myv.newMap.addMapType(customMapType); mc.myv.newMap.setMapType(customMapType); } |
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 | package com.first.map { import com.google.maps.Color; import com.google.maps.Copyright; import com.google.maps.CopyrightCollection; import com.google.maps.LatLng; import com.google.maps.LatLngBounds; import com.google.maps.TileLayerBase; import com.google.maps.interfaces.IMap; import flash.display.DisplayObject; import flash.display.Loader; import flash.display.LoaderInfo; import flash.display.Sprite; import flash.events.*; import flash.geom.Point; import flash.net.URLRequest; import mx.controls.Alert; public class CustomTileLayer extends TileLayerBase { private var tileSize: Number ; /** * Campus tile layer constructor. * @param tileSize Tile size (same horizontally and vertically). */ public function CustomTileLayer(tileSize: Number ) { var copyrightCollection:CopyrightCollection = new CopyrightCollection(); super (copyrightCollection, 1 , 20 ); this .tileSize = tileSize; // Add a custom copyright that will apply to the entire map layer. copyrightCollection.addCopyright( new Copyright( "CustomCopyright" , new LatLngBounds( new LatLng(- 90 , - 180 ), new LatLng( 90 , 180 )), 0 , "" )); } /** * Creates and loads a tile (x, y) at the given zoom level. * @param tilePos Tile coordinates. * @param zoom Tile zoom. * @return Display object representing the tile. */ public override function loadTile(tilePos:Point, zoom: Number ):DisplayObject { var testLoader:Loader = new Loader(); var z: Number = 17 - zoom; // var tileUrl:String = "http://web-app.usc.edu/maps/images_3d/index.php?x=" + tilePos.x + "&y=" + tilePos.y + "&zoom=" + z; // var tileUrl:String = "http://tiles.mycompany.com/tile_" + tilePos.x + "_" + tilePos.y + "_" + zoom + ".png"; var tileUrl: String = "../img/mappattern.png" ; var urlRequest:URLRequest = new URLRequest(tileUrl); testLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); testLoader.load(urlRequest); return testLoader; } private function ioErrorHandler(event:IOErrorEvent): void { trace ( "ioErrorHandler: " + event); } } } |
아래는 결과입니다.
반응형
'컴퓨터관련' 카테고리의 다른 글
ORACLE - 시작일자와 종료일자 사이의 날짜 가져오기 (0) | 2016.01.20 |
---|---|
ORACLE - Local에서 Listener가 동작하지 않을 경우 (0) | 2016.01.20 |
베다수학 정리 (0) | 2016.01.20 |
C언어 - 내일 날짜 가져오기 (0) | 2016.01.20 |
SyntaxHighlighter 에서 linenumber 표시하지 않기 (0) | 2016.01.20 |