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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
| <?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:os="http://openscales.org"
xmlns:g="fx.*"
xmlns:component="fx.component.*"
creationComplete="initMap();"
applicationComplete="init()"
frameRate="71" xmlns:core="core.*">
<fx:Script>
<![CDATA[
import core.Catalogue;
import core.control.panel.InfosPanel;
import core.control.panel.LayersPanel;
import core.control.panel.LogoPanel;
import core.control.panel.ToolsPanel;
import core.layer.GeoportalKML;
import core.layer.gppWMSC;
import flash.system.Security;
import mx.controls.Alert;
import org.openscales.core.Map;
import org.openscales.core.events.FeatureEvent;
import org.openscales.core.layer.Layer;
import org.openscales.core.popup.Anchored;
import org.openscales.geometry.basetypes.Pixel;
import org.openscales.geometry.basetypes.Size;
[Bindable] private var map:Map = null;
[Bindable] public var host:String= null;
[Bindable] public var wmsc:String= null;
[Bindable] public var proxy:String= null;
[Bindable] public var key:String= null;
[Bindable] public var center:String= null;
[Bindable] public var zoom:String= null;
[Bindable] public var kmlLayer:String= null;
[Embed(source="/assets/logo_ign.png")]
private var logoIGN:Class;
[Embed(source="/assets/logo_planetobserver.gif")]
private var logoPO:Class;
private var popup:Anchored;
private function initMap():void {
map = fxmap.map;
//add data providers' logos
cartes.visible = false;
var imageIGN:Bitmap = new logoIGN();
(cartes.layer as gppWMSC).originators = {img:imageIGN,url:"http://www.ign.fr"};
var imagePO:Bitmap = new logoPO();
(ortho.layer as gppWMSC).originators = {img:imagePO,url:"http://www.planetobserver.com"};
//catalog
var catalog:Catalogue = new Catalogue(this.map);
//add KML layers from flashvars
if(kmlLayer != null){
var kmlLayers:Array = kmlLayer.split(",");
for(var i:int=0;i<kmlLayers.length;i++){
var name:String = kmlLayers[i].toString().split('@')[0];
var url : String = kmlLayers[i].toString().split('@')[1];
var kml:GeoportalKML = new GeoportalKML(name,url,null);
if(url.indexOf("http://",0) != -1){
kml.proxy = proxy;
}
kml.tweenOnZoom = false;
map.addLayer(kml);
}
map.addEventListener(FeatureEvent.FEATURE_CLICK, onFeatureClick);
}
//add controls
map.addControl(new LayersPanel(new Pixel(0,0),layerspanel));
map.addControl(new InfosPanel(new Pixel(0,0),infospanel));
map.addControl(new ToolsPanel(new Pixel(0,0),toolspanel));
map.addControl(new LogoPanel());
}
/*
*Open a popup on clicking a feature
*/
private function onFeatureClick(event:FeatureEvent):void {
if(popup) {
popup.destroy();
}
popup = null;
popup = new Anchored();
popup.size = new Size(200,100);
popup.feature = event.feature;
map.addPopup(popup, true);
}
/*
*Load the flashvars parameters
*/
private function loadParams():void{
zoom = this.parameters.zoom;
if(zoom == null){
zoom = "15";
}
center = this.parameters.center;
if(center == null){
center = "4.243575,45.048677";//Mazet
}
proxy= this.parameters.proxy;
if (proxy==null) {
// proxy= "http://api.ign.fr/geoportail/api/osproxy?url=";
proxy= "proxyFlashIGN.php?url=";
}
host= this.parameters.host;
if (host==null) {
host= "http://jeton-api.ign.fr";
}
wmsc = this.parameters.wmsc;
if (wmsc==null) {
wmsc= "http://wxs.ign.fr/geoportail/wmsc";
}
key = this.parameters.key;
if(key == null){
key = "7391965370598559221";
}
if(this.parameters.kmlLayers){
kmlLayer = this.parameters.kmlLayers;
}
}
]]>
</fx:Script>
<s:VGroup width="100%" height="100%" gap="0">
<s:SpriteVisualElement id="layerspanel" width="100%" height="30">
</s:SpriteVisualElement>
<s:Group width="100%" height="100%">
<os:Map id="fxmap"
width="100%"
height="100%"
zoom="{zoom}"
center="{center}"
x="0"
y="0"
preinitialize="loadParams()" >
<os:IGNGeoRMSecurity key="{key}"
layers="ORTHOIMAGERY.ORTHOPHOTOS,GEOGRAPHICALGRIDSYSTEMS.MAPS"
method="POST"
host="{host}"/>
<core:FxWMSC id="cartes"
name="GEOGRAPHICALGRIDSYSTEMS.MAPS"
url="{wmsc}"
layers="GEOGRAPHICALGRIDSYSTEMS.MAPS"
format="image/jpeg"
resolutions="39135.75,19567.875,9783.9375,4891.96875,2445.984375,2048,1024,512,256,128,64,32,16,8,4,2,1,0.5,0.25,0.125,0.0625"
projection="IGNF:GEOPORTALFXX"
minZoomLevel="5"
maxZoomLevel="17"
maxExtent="-1048576,3670016,2097152,6815744"
exceptions="text/xml"
visible="true"
method="POST"
/>
<core:FxWMSC id="ortho"
name="ORTHOIMAGERY.ORTHOPHOTOS"
url="{wmsc}"
layers="ORTHOIMAGERY.ORTHOPHOTOS"
format="image/jpeg"
resolutions="39135.75,19567.875,9783.9375,4891.96875,2445.984375,2048,1024,512,256,128,64,32,16,8,4,2,1,0.5,0.25,0.125,0.0625"
projection="IGNF:GEOPORTALFXX"
minZoomLevel="5"
maxZoomLevel="17"
maxExtent="-1048576,3670016,2097152,6815744"
exceptions="text/xml"
visible="false"
method="POST"
/>
<os:DragHandler/>
<os:ClickHandler/>
<os:WheelHandler/>
</os:Map>
<os:PanZoom map="{map}" x="{fxmap.x+10}" y="{fxmap.y+10}"/>
</s:Group>
<s:SpriteVisualElement id="toolspanel" width="100%" height="32">
</s:SpriteVisualElement>
<s:SpriteVisualElement id="infospanel" width="100%" height="26">
</s:SpriteVisualElement>
</s:VGroup>
</s:Application> |
Partager