Repository: flex-asjs Updated Branches: refs/heads/core_js_to_as 46e3dc61a -> 5f4274856
Back port of GoogleMaps FlexJS project. Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/5f427485 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/5f427485 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/5f427485 Branch: refs/heads/core_js_to_as Commit: 5f427485663076183d2c466985640a633ab64174 Parents: 46e3dc6 Author: Peter Ent <[email protected]> Authored: Mon Dec 14 11:58:37 2015 -0500 Committer: Peter Ent <[email protected]> Committed: Mon Dec 14 11:58:37 2015 -0500 ---------------------------------------------------------------------- frameworks/projects/GoogleMaps/as/defaults.css | 5 +- .../GoogleMaps/as/src/GoogleMapsClasses.as | 3 + .../src/org/apache/flex/maps/google/Geometry.as | 30 -- .../org/apache/flex/maps/google/GoogleMap.as | 138 ++++++ .../src/org/apache/flex/maps/google/LatLng.as | 30 -- .../as/src/org/apache/flex/maps/google/Map.as | 233 ---------- .../src/org/apache/flex/maps/google/Marker.as | 32 -- .../as/src/org/apache/flex/maps/google/Place.as | 43 -- .../flex/maps/google/beads/GoogleMapView.as | 435 +++++++++++++++++++ .../apache/flex/maps/google/beads/MapView.as | 154 ++++--- .../apache/flex/maps/google/models/MapModel.as | 39 +- frameworks/projects/GoogleMaps/build.xml | 120 +++-- .../projects/GoogleMaps/compile-asjs-config.xml | 70 +++ .../projects/GoogleMaps/compile-config.xml | 1 + .../projects/GoogleMaps/google-manifest.xml | 2 +- 15 files changed, 852 insertions(+), 483 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f427485/frameworks/projects/GoogleMaps/as/defaults.css ---------------------------------------------------------------------- diff --git a/frameworks/projects/GoogleMaps/as/defaults.css b/frameworks/projects/GoogleMaps/as/defaults.css index 6c260d5..260517a 100644 --- a/frameworks/projects/GoogleMaps/as/defaults.css +++ b/frameworks/projects/GoogleMaps/as/defaults.css @@ -19,9 +19,10 @@ @namespace g "library://ns.apache.org/flexjs/google"; -g|Map +g|GoogleMap { - IBeadView: ClassReference("org.apache.flex.maps.google.beads.MapView"); + IBeadView: ClassReference("org.apache.flex.maps.google.beads.GoogleMapView"); + IBeadModel: ClassReference("org.apache.flex.maps.google.models.MapModel"); } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f427485/frameworks/projects/GoogleMaps/as/src/GoogleMapsClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/GoogleMaps/as/src/GoogleMapsClasses.as b/frameworks/projects/GoogleMaps/as/src/GoogleMapsClasses.as index cd424fe..6445519 100644 --- a/frameworks/projects/GoogleMaps/as/src/GoogleMapsClasses.as +++ b/frameworks/projects/GoogleMaps/as/src/GoogleMapsClasses.as @@ -27,6 +27,9 @@ package */ internal class GoogleMapsClasses { + import org.apache.flex.maps.google.GoogleMap; GoogleMap; + import org.apache.flex.maps.google.models.MapModel; MapModel; + import org.apache.flex.maps.google.beads.GoogleMapView; GoogleMapView; } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f427485/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/Geometry.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/Geometry.as b/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/Geometry.as deleted file mode 100644 index 4546bf0..0000000 --- a/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/Geometry.as +++ /dev/null @@ -1,30 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.maps.google -{ - public class Geometry - { - public function Geometry() - { - location = new LatLng(); - } - - public var location:LatLng; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f427485/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/GoogleMap.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/GoogleMap.as b/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/GoogleMap.as new file mode 100644 index 0000000..64ae26b --- /dev/null +++ b/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/GoogleMap.as @@ -0,0 +1,138 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.maps.google +{ + import org.apache.flex.core.IBeadModel; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.UIBase; + import org.apache.flex.core.ValuesManager; + import org.apache.flex.events.Event; + import org.apache.flex.maps.google.beads.GoogleMapView; + import org.apache.flex.maps.google.models.MapModel; + + COMPILE::JS { + import google.maps.LatLng; + import google.maps.Marker; + import org.apache.flex.core.WrappedHTMLElement; + } + + [Event(name="ready", type="org.apache.flex.events.Event")] + [Event(name="centered", type="org.apache.flex.events.Event")] + [Event(name="boundsChanged", type="org.apache.flex.events.Event")] + [Event(name="zoomChanged", type="org.apache.flex.events.Event")] + [Event(name="dragEnd", type="org.apache.flex.events.Event")] + [Event(name="searchResult", type="org.apache.flex.events.Event")] + + /** + * The Map class displays a Google Map centered on lat/lng coordinates. The Map uses + * the following bead type: + * + * org.apache.flex.maps.beads.MapView: Uses HTMLLoader to display the map. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + * @flexjsignoreimport goog.bind + * @flexjsignoreimport google.maps.event + */ + public class GoogleMap extends UIBase + { + + public function GoogleMap() + { + super(); + + className = "Map"; + + var model:IBeadModel = getBeadByType(IBeadModel) as IBeadModel; + if (model == null) { + model = new MapModel(); + addBead(model); + } + } + + public function get token():String + { + return MapModel(model).token; + } + public function set token(value:String):void + { + MapModel(model).token = value; + } + + COMPILE::JS + public function get selectedMarker():Marker + { + return MapModel(model).selectedMarker; + } + + public function get searchResults():Array + { + return MapModel(model).searchResults; + } + + public function loadMap( centerLat:Number, centerLong:Number, zoom:Number ) : void + { + GoogleMapView(view).mapit(centerLat, centerLong, zoom); + } + + public function setZoom(zoomLevel:Number):void + { + MapModel(model).zoom = zoomLevel; + } + + public function centerOnAddress(address:String):void + { + GoogleMapView(view).centerOnAddress(address); + } + + COMPILE::JS + public function setCenter(location:LatLng):void + { + GoogleMapView(view).setCenter(location); + } + + public function markCurrentLocation():void + { + GoogleMapView(view).markCurrentLocation(); + } + + public function markAddress(address:String):void + { + GoogleMapView(view).markAddress(address); + } + + COMPILE::JS + public function createMarker(location:LatLng):Marker + { + return GoogleMapView(view).createMarker(location); + } + + public function nearbySearch(placeName:String):void + { + GoogleMapView(view).nearbySearch(placeName); + } + + public function clearSearchResults():void + { + GoogleMapView(view).clearSearchResults(); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f427485/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/LatLng.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/LatLng.as b/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/LatLng.as deleted file mode 100644 index 80e688c..0000000 --- a/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/LatLng.as +++ /dev/null @@ -1,30 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.maps.google -{ - public class LatLng - { - public function LatLng() - { - } - - public var lat:Number; - public var lng:Number; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f427485/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/Map.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/Map.as b/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/Map.as deleted file mode 100644 index 1d289a7..0000000 --- a/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/Map.as +++ /dev/null @@ -1,233 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.maps.google -{ - import org.apache.flex.core.IBeadModel; - import org.apache.flex.core.IBeadView; - import org.apache.flex.core.UIBase; - import org.apache.flex.core.ValuesManager; - import org.apache.flex.maps.google.beads.MapView; - import org.apache.flex.maps.google.models.MapModel; - - [Event(name="ready", type="org.apache.flex.events.Event")] - [Event(name="centered", type="org.apache.flex.events.Event")] - [Event(name="boundsChanged", type="org.apache.flex.events.Event")] - [Event(name="zoomChanged", type="org.apache.flex.events.Event")] - [Event(name="dragEnd", type="org.apache.flex.events.Event")] - [Event(name="searchResult", type="org.apache.flex.events.Event")] - - /** - * The Map class displays a Google Map centered on lat/lng coordinates. The Map uses - * the following bead type: - * - * org.apache.flex.maps.beads.MapView: Uses HTMLLoader to display the map. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public class Map extends UIBase - { - /** - * constructor. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function Map() - { - super(); - - var model:IBeadModel = getBeadByType(IBeadModel) as IBeadModel; - if (model == null) { - model = new MapModel(); - addBead(model); - } - } - - private var _token:String; - - /** - * The Google API developer token. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function set token(value:String):void - { - _token = value; - } - /** - * @private - */ - public function get token():String - { - return _token; - } - - public var searchResults:Array; - - /** - * The marker last selected. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get selectedMarker():Marker - { - return MapModel(model).selectedMarker; - } - - /** - * Loads a map centered on the given latitude and longitude coodinates at the - * zoom level provided. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function loadMap( centerLat:Number, centerLong:Number, zoom:Number ) : void - { - var viewBead:MapView = getBeadByType(IBeadView) as MapView; - if (viewBead) { - viewBead.mapit(centerLat, centerLong, zoom); - } - } - - /** - * Sets the magnification level on the map with 1 being the lowest level - * (essentially the entire world) and 14 being very zoomed. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function setZoom( zoom:Number ) : void - { - MapModel(model).zoom = zoom; - } - - /** - * Centers the map on the address given. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function centerOnAddress( address:String ) : void - { - var viewBead:MapView = getBeadByType(IBeadView) as MapView; - if (viewBead) { - viewBead.centerOnAddress(address); - } - } - - /** - * Centers the map on a specific location. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function setCenter( location:LatLng ) : void - { - var geo:Geometry = new Geometry(); - geo.location = location; - MapModel(model).currentLocation = geo; - } - - /** - * Marks the current center of the map. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function markCurrentLocation() : void - { - var viewBead:MapView = getBeadByType(IBeadView) as MapView; - if (viewBead) { - viewBead.markCurrentLocation(); - } - } - - /** - * Performs a search near the center of map. The result is a set of - * markers displayed on the map. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function nearbySearch(placeName:String):void - { - var viewBead:MapView = getBeadByType(IBeadView) as MapView; - if (viewBead) { - viewBead.nearbySearch(placeName); - } - } - - /** - * Clears the search result markers from the map. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function clearSearchResults():void - { - var viewBead:MapView = getBeadByType(IBeadView) as MapView; - if (viewBead) { - viewBead.removeAllMarkers(); - } - MapModel(model).searchResults = []; - } - - /** - * Translates the given address into a geo-location, moves the map to - * that location, and places a marker on that location. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function markAddress( address:String ) : void - { - var viewBead:MapView = getBeadByType(IBeadView) as MapView; - if (viewBead) { - viewBead.geoCodeAndMarkAddress(address); - } - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f427485/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/Marker.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/Marker.as b/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/Marker.as deleted file mode 100644 index 9c7ff0d..0000000 --- a/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/Marker.as +++ /dev/null @@ -1,32 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.maps.google -{ - public class Marker - { - public function Marker() - { - position = new LatLng(); - } - - public var position:LatLng; - public var title:String; - public var map:Map; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f427485/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/Place.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/Place.as b/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/Place.as deleted file mode 100644 index cb08703..0000000 --- a/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/Place.as +++ /dev/null @@ -1,43 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.maps.google -{ - public class Place - { - public function Place() - { - geometry = new Geometry(); - } - - public var geometry:Geometry; - public var icon:String; - public var id:String; - public var name:String; - public var reference:String; - public var vicinity:String; - - public function toString():String - { - var results:String = ""; - if (name) results = name; - if (vicinity) results += " "+vicinity; - return results; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f427485/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/beads/GoogleMapView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/beads/GoogleMapView.as b/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/beads/GoogleMapView.as new file mode 100644 index 0000000..61c31e3 --- /dev/null +++ b/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/beads/GoogleMapView.as @@ -0,0 +1,435 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.apache.flex.maps.google.beads +{ + COMPILE::AS3 { + import flash.events.Event; + import flash.html.HTMLLoader; + import flash.net.URLRequest; + } + + import org.apache.flex.core.BeadViewBase; + import org.apache.flex.core.IBeadModel; + import org.apache.flex.core.IBeadView; + import org.apache.flex.core.IStrand; + import org.apache.flex.core.UIBase; + import org.apache.flex.events.Event; + import org.apache.flex.events.IEventDispatcher; + import org.apache.flex.maps.google.GoogleMap; + import org.apache.flex.maps.google.models.MapModel; + + COMPILE::JS { + import goog.bind; + import google.maps.event; + import google.maps.Geocoder; + import google.maps.GeocoderResult; + import google.maps.GeocoderStatus; + import google.maps.LatLng; + import google.maps.Map; + import google.maps.Marker; + import google.maps.places.PlaceResult; + import google.maps.places.PlacesService; + import google.maps.places.PlacesServiceStatus; + } + + /** + * The MapView bead class displays a Google Map using HTMLLoader. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + COMPILE::JS + public class GoogleMapView extends BeadViewBase implements IBeadView + { + public function GoogleMapView() + { + super(); + } + + private var map:Map; + private var geocoder:Geocoder; + private var initialized:Boolean = false; + private var markers:Array; + private var searchResults:Array; + private var service:PlacesService; + + private var _strand:IStrand; + + override public function set strand(value:IStrand):void + { + super.strand = value; + _strand = value; + + var token:String = (_strand as GoogleMap).token; + var src:String = 'https://maps.googleapis.com/maps/api/js?v=3.exp'; + if (token) + src += '&key=' + token; + src += '&libraries=places&sensor=false&callback=mapInit'; + + var script:HTMLScriptElement = document.createElement('script') as HTMLScriptElement; + script.type = 'text/javascript'; + script.src = src; + + window['mapView'] = this; + window['mapInit'] = function():void { + (this['mapView'] as GoogleMapView).finishInitialization(); + } + + document.head.appendChild(script); + + var model:MapModel = _strand.getBeadByType(IBeadModel) as MapModel; + model.addEventListener("zoomChanged", handleModelChange); + } + + public function mapit( centerLat:Number, centerLng:Number, zoom:Number ):void + { + if (!initialized) { + var model:MapModel = _strand.getBeadByType(IBeadModel) as MapModel; + model.currentCenter = new LatLng(centerLat, centerLng); + model.zoom = zoom; + var mapOptions:Object = new Object(); + mapOptions['center'] = model.currentCenter; + mapOptions['zoom'] = zoom; + + map = new Map((_strand as UIBase).element, mapOptions); + geocoder = null; + + google.maps.event.addListener(map, 'center_changed', goog.bind(centerChangeHandler, this)); + google.maps.event.addListener(map, 'bounds_changed', goog.bind(boundsChangeHandler, this)); + google.maps.event.addListener(map, 'zoom_changed', goog.bind(zoomChangeHandler, this)); + } + } + + private function finishInitialization():void + { + mapit(37.333, -121.900, 12); + initialized = true; + dispatchEvent(new Event('ready')); + } + + public function centerOnAddress(value:String):void + { + if (geocoder == null) geocoder = new Geocoder(); + geocoder.geocode({address:value}, positionHandler); + } + + public function setCenter(location:LatLng):void + { + var model:MapModel = _strand.getBeadByType(IBeadModel) as MapModel; + model.currentCenter = new LatLng(location.lat(), location.lng()); + map.setCenter(model.currentCenter as LatLng); + } + + public function markCurrentLocation():void + { + var model:MapModel = _strand.getBeadByType(IBeadModel) as MapModel; + createMarker(model.currentCenter as LatLng); + } + + public function markAddress(address:String):void + { + if (initialized) { + if (geocoder == null) geocoder = new Geocoder(); + geocoder.geocode({address:address}, geocodeHandler); + } + } + + public function createMarker(location:LatLng):Marker + { + var marker:Marker = new Marker({map:map, position:location}); + google.maps.event.addListener(marker, 'click', goog.bind(markerClicked, this)); + return marker; + } + + public function nearbySearch(placeName:String):void + { + var model:MapModel = _strand.getBeadByType(IBeadModel) as MapModel; + + if (markers == null) markers = []; + service = new PlacesService(map); + service.nearbySearch({location:model.currentCenter, radius:5000, name:placeName}, searchResultsHandler); + } + + public function clearSearchResults():void + { + if (markers) { + for(var i:int=0; i < markers.length; i++) { + var m:Marker = markers[i] as Marker; + m.setMap(null); + } + markers = null; + } + } + + // Callbacks + + public function centerChangeHandler() : void + { + var model:MapModel = _strand.getBeadByType(IBeadModel) as MapModel; + model.currentCenter = map.getCenter(); + + var newEvent:Event = new Event('centered'); + (_strand as IEventDispatcher).dispatchEvent(newEvent); + } + + public function boundsChangeHandler():void + { + var model:MapModel = _strand.getBeadByType(IBeadModel) as MapModel; + model.currentCenter = map.getCenter(); + + var newEvent:Event = new Event('boundsChanged'); + (_strand as IEventDispatcher).dispatchEvent(newEvent); + } + + public function zoomChangeHandler():void + { + var model:MapModel = _strand.getBeadByType(IBeadModel) as MapModel; + model.currentCenter = map.getCenter(); + + var newEvent:Event = new Event('zoomChanged'); + (_strand as IEventDispatcher).dispatchEvent(newEvent); + } + + public function positionHandler(results, status):void + { + var model:MapModel = _strand.getBeadByType(IBeadModel) as MapModel; + if (status == GeocoderStatus.OK) { + model.currentCenter = results[0].geometry.location; + map.setCenter(model.currentCenter as LatLng); + + // dispatch an event to indicate the map has been centered + } + } + + public function geocodeHandler(results, status):void + { + var model:MapModel = _strand.getBeadByType(IBeadModel) as MapModel; + if (status == GeocoderStatus.OK) { + model.currentCenter = results[0].geometry.location; + map.setCenter(model.currentCenter as LatLng); + + var marker:Marker = new Marker({map:map, position:model.currentCenter}); + } + } + + public function searchResultsHandler(results, status):void + { + searchResults = []; + if (status == PlacesServiceStatus.OK) { + for(var i:int=0; i < results.length; i++) { + var place:PlaceResult = new PlaceResult(); + place.geometry.location = new LatLng(results[i].geometry.location.lat(), results[i].geometry.location.lng()); + place.icon = results[i].icon; + place.id = results[i].id; + place.name = results[i].name; + place.reference = results[i].reference; + place.vicinity = results[i].vicinity; + searchResults.push(place); + + var marker:Marker = createMarker(place.geometry.location); + marker.setTitle(place.name); + + markers.push(marker); + } + var model:MapModel = _strand.getBeadByType(IBeadModel) as MapModel; + model.searchResults = searchResults; + } + } + + // Event handlers + + /** + * Handles changes to properties of the MapModel. When this value is + * changed, the map itself has its zoom changed. This will trigger an + * event on the map that will be handled by functions above. + */ + public function handleModelChange(event:Event):void + { + if (event.type == "zoomChanged") { + var model:MapModel = _strand.getBeadByType(IBeadModel) as MapModel; + map.setZoom(model.zoom); + } + } + + public function markerClicked(marker:Marker, event:Object):void + { + var newMarker:Marker = new Marker(); + newMarker.setPosition(new LatLng(marker.getPosition().lat(), marker.getPosition().lng())); + newMarker.setTitle(marker.getTitle()); + newMarker.setMap(map); + + var model:MapModel = _strand.getBeadByType(IBeadModel) as MapModel; + model.selectedMarker = newMarker; + + var newEvent:Event = new Event('markerClicked'); + dispatchEvent(newEvent); + } + + } // end ::JS + + /** + * The AS3 version of GoogleMapView is geared toward its use with HTMLLoader + * for AIR. + */ + COMPILE::AS3 + public class GoogleMapView extends BeadViewBase implements IBeadView + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function GoogleMapView() + { + super(); + } + + private var _loader:HTMLLoader; + + /** + * @copy org.apache.flex.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + override public function set strand(value:IStrand):void + { + super.strand = value; + } + + /** + * Adjusts the map to the given coordinate and zoom level. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function mapit(lat:Number, lng:Number, zoomLevel:Number):void + { + + } + + /** + * Finds the given address and places a marker on it. This function may be dropped + * since centerOnAddress + markCurrentLocation does the same thing. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function markAddress(address:String):void + { + + } + + /** + * Centers the map on the address given. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function centerOnAddress(address:String):void + { + + } + + /** + * Marks the current center of the map. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function markCurrentLocation():void + { + + } + + /** + * Performs a search near the center of map. The result is a set of + * markers displayed on the map. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function nearbySearch(placeName:String):void + { + + } + + /** + * Removes all of the markers from the map + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function removeAllMarkers():void + { + + } + + /** + * Sets the zoom factor of the map. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function setZoom(zoom:Number):void + { + + } + + /** + * Sets the center of the map. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function setCenter( location:Object ):void + { + + } + + public function clearSearchResults():void + { + // not implemented + } + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f427485/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/beads/MapView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/beads/MapView.as b/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/beads/MapView.as index 5e71187..5cf153f 100644 --- a/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/beads/MapView.as +++ b/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/beads/MapView.as @@ -16,12 +16,22 @@ // limitations under the License. // //////////////////////////////////////////////////////////////////////////////// + +/** + * NOTE + * + * THIS IS THE OLD MapView. The new one is GoogleMapView. This code exists to preserve + * the AS/HTMLLoader version for use with AIR. Someday we will come back to this and make + * it work again. + */ package org.apache.flex.maps.google.beads { - import flash.events.Event; - import flash.html.HTMLLoader; - import flash.net.URLRequest; - + COMPILE::AS3 { + import flash.events.Event; + import flash.html.HTMLLoader; + import flash.net.URLRequest; + } + import org.apache.flex.core.BeadViewBase; import org.apache.flex.core.IBeadModel; import org.apache.flex.core.IBeadView; @@ -29,20 +39,52 @@ package org.apache.flex.maps.google.beads import org.apache.flex.core.UIBase; import org.apache.flex.events.Event; import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.maps.google.LatLng; - import org.apache.flex.maps.google.Map; - import org.apache.flex.maps.google.Marker; - import org.apache.flex.maps.google.Place; + import org.apache.flex.maps.google.GoogleMap; import org.apache.flex.maps.google.models.MapModel; - + /** * The MapView bead class displays a Google Map using HTMLLoader. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::JS + public class MapView extends BeadViewBase implements IBeadView + { + public function MapView() + { + super(); + } + + private var _strand:IStrand; + + override public function set strand(value:IStrand):void + { + super.strand = value; + _strand = value; + + var token:String = (_strand as GoogleMap).token; + var src:String = 'https://maps.googleapis.com/maps/api/js?v=3.exp'; + if (token) + src += '&key=' + token; + src += '&libraries=places&sensor=false&callback=mapInit'; + + var script:HTMLScriptElement = document.createElement('script') as HTMLScriptElement; + script.type = 'text/javascript'; + script.src = src; + +/** window.mapView = this; + window['mapInit'] = function() { + (this.mapView._strand as GoogleMap).finishInitialization(); + } +**/ + document.head.appendChild(script); + } + } + + COMPILE::AS3 public class MapView extends BeadViewBase implements IBeadView { /** @@ -56,12 +98,12 @@ package org.apache.flex.maps.google.beads public function MapView() { } - + private var _loader:HTMLLoader; - + /** * @copy org.apache.flex.core.IBead#strand - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -70,52 +112,52 @@ package org.apache.flex.maps.google.beads override public function set strand(value:IStrand):void { super.strand = value; - + _loader = new HTMLLoader(); _loader.x = 0; _loader.y = 0; _loader.width = UIBase(value).width; _loader.height = UIBase(value).height; - + IEventDispatcher(_strand).addEventListener("widthChanged",handleSizeChange); IEventDispatcher(_strand).addEventListener("heightChanged",handleSizeChange); - + var model:IBeadModel = _strand.getBeadByType(IBeadModel) as IBeadModel; model.addEventListener("zoomChanged", handleZoomChange); model.addEventListener("currentLocationChanged", handleCurrentLocationChange); - + (_strand as UIBase).addChild(_loader); - + var token:String = Map(_strand).token; if (token) page = pageTemplateStart + "&key=" + token + pageTemplateEnd; else page = pageTemplateStart + pageTemplateEnd; - + if (page) { _loader.loadString(page); _loader.addEventListener(flash.events.Event.COMPLETE, completeHandler); } } - + private function completeHandler(event:flash.events.Event):void { trace("htmlLoader complete"); - + if (_loader && page) { _loader.window.map.center_changed = onMapCentered; _loader.window.map.bounds_changed = onMapBoundsChanged; _loader.window.map.zoom_changed = onMapZoomChanged; _loader.window.map.dragend = onMapDragEnd; - + // custom event handlers _loader.window.addEventListener("searchResults",onSearchResults); _loader.window.addEventListener("markerClicked",onMarkerClicked); } - + IEventDispatcher(_strand).dispatchEvent(new org.apache.flex.events.Event("ready")); } - + private function handleZoomChange(event:org.apache.flex.events.Event):void { if (_loader && page) { @@ -123,7 +165,7 @@ package org.apache.flex.maps.google.beads setZoom(model.zoom); } } - + private function handleCurrentLocationChange(event:org.apache.flex.events.Event):void { if (_loader && page) { @@ -131,12 +173,12 @@ package org.apache.flex.maps.google.beads setCenter(model.currentLocation.location); } } - + private var page:String; - + /** * Adjusts the map to the given coordinate and zoom level. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -148,11 +190,11 @@ package org.apache.flex.maps.google.beads _loader.window.mapit(lat,lng,zoomLevel); } } - + /** * Finds the given address and places a marker on it. This function may be dropped * since centerOnAddress + markCurrentLocation does the same thing. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -164,10 +206,10 @@ package org.apache.flex.maps.google.beads _loader.window.codeaddress(address); } } - + /** * Centers the map on the address given. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -179,10 +221,10 @@ package org.apache.flex.maps.google.beads _loader.window.centeronaddress(address); } } - + /** * Marks the current center of the map. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -194,11 +236,11 @@ package org.apache.flex.maps.google.beads _loader.window.markcurrentlocation(); } } - + /** * Performs a search near the center of map. The result is a set of * markers displayed on the map. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -210,10 +252,10 @@ package org.apache.flex.maps.google.beads _loader.window.nearbysearch(placeName); } } - + /** * Removes all of the markers from the map - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -225,10 +267,10 @@ package org.apache.flex.maps.google.beads _loader.window.clearmarkers(); } } - + /** * Sets the zoom factor of the map. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -240,10 +282,10 @@ package org.apache.flex.maps.google.beads _loader.window.map.setZoom(zoom); } } - + /** * Sets the center of the map. - * + * * @langversion 3.0 * @playerversion Flash 10.2 * @playerversion AIR 2.6 @@ -255,7 +297,7 @@ package org.apache.flex.maps.google.beads _loader.window.setCenter(location.lat, location.lng); } } - + /** * @private */ @@ -264,7 +306,7 @@ package org.apache.flex.maps.google.beads _loader.width = UIBase(_strand).width; _loader.height = UIBase(_strand).height; } - + /** * @private */ @@ -272,7 +314,7 @@ package org.apache.flex.maps.google.beads { IEventDispatcher(_strand).dispatchEvent( new org.apache.flex.events.Event("centered") ); } - + /** * @private */ @@ -280,7 +322,7 @@ package org.apache.flex.maps.google.beads { IEventDispatcher(_strand).dispatchEvent( new org.apache.flex.events.Event("boundsChanged") ); } - + /** * @private */ @@ -288,7 +330,7 @@ package org.apache.flex.maps.google.beads { IEventDispatcher(_strand).dispatchEvent( new org.apache.flex.events.Event("zoomChanged") ); } - + /** * @private */ @@ -296,7 +338,7 @@ package org.apache.flex.maps.google.beads { IEventDispatcher(_strand).dispatchEvent( new org.apache.flex.events.Event("dragEnd") ); } - + /** * @private */ @@ -314,11 +356,11 @@ package org.apache.flex.maps.google.beads result.vicinity = event.results[i].vicinity; results.push(result); } - + var model:MapModel = _strand.getBeadByType(IBeadModel) as MapModel; model.searchResults = results; } - + /** * @private */ @@ -329,13 +371,13 @@ package org.apache.flex.maps.google.beads marker.position.lng = event.marker.position.lng(); marker.title = event.marker.title; marker.map = Map(_strand); - + var model:MapModel = _strand.getBeadByType(IBeadModel) as MapModel; model.selectedMarker = marker; - + IEventDispatcher(_strand).dispatchEvent(new org.apache.flex.events.Event("markerClicked")); } - + /** * @private * This page definition is used with HTMLLoader to bring in the Google Maps @@ -352,7 +394,7 @@ package org.apache.flex.maps.google.beads ' </style>'+ ' <script type="text/javascript"'+ ' src="https://maps.googleapis.com/maps/api/js?v=3.exp'; - + private static var pageTemplateEnd:String = '&libraries=places&sensor=false">'+ ' </script>'+ ' <script type="text/javascript">'+ @@ -469,5 +511,5 @@ package org.apache.flex.maps.google.beads ' </body>'+ '</html>'; } - -} \ No newline at end of file + +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f427485/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/models/MapModel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/models/MapModel.as b/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/models/MapModel.as index 08ac171..d988e3b 100644 --- a/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/models/MapModel.as +++ b/frameworks/projects/GoogleMaps/as/src/org/apache/flex/maps/google/models/MapModel.as @@ -22,8 +22,11 @@ package org.apache.flex.maps.google.models import org.apache.flex.core.IStrand; import org.apache.flex.events.Event; import org.apache.flex.events.EventDispatcher; - import org.apache.flex.maps.google.Geometry; - import org.apache.flex.maps.google.Marker; + + COMPILE::JS { + import google.maps.LatLng; + import google.maps.Marker; + } /** * The data model for the Map class, this holds the maps current center @@ -65,7 +68,20 @@ package org.apache.flex.maps.google.models _strand = value; } - private var _currentLocation:Geometry; + private var _token:String; + + public function get token():String + { + return _token; + } + public function set token(value:String):void + { + _token = value; + dispatchEvent(new Event("tokenChanged")); + } + + COMPILE::JS + private var _currentCenter:LatLng; /** * The current center of the map. @@ -75,16 +91,20 @@ package org.apache.flex.maps.google.models * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public function get currentLocation():Geometry + COMPILE::JS + public function get currentCenter():LatLng { - return _currentLocation; + return _currentCenter; } - public function set currentLocation(value:Geometry):void + + COMPILE::JS + public function set currentCenter(value:LatLng):void { - _currentLocation = value; - dispatchEvent( new Event("currentLocationChanged") ); + _currentCenter = value; + dispatchEvent( new Event("currentCenterChanged") ); } + COMPILE::JS private var _selectedMarker:Marker; /** @@ -95,10 +115,13 @@ package org.apache.flex.maps.google.models * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ + COMPILE::JS public function get selectedMarker():Marker { return _selectedMarker; } + + COMPILE::JS public function set selectedMarker(value:Marker):void { _selectedMarker = value; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f427485/frameworks/projects/GoogleMaps/build.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/GoogleMaps/build.xml b/frameworks/projects/GoogleMaps/build.xml index 00fbee9..606e30c 100644 --- a/frameworks/projects/GoogleMaps/build.xml +++ b/frameworks/projects/GoogleMaps/build.xml @@ -28,28 +28,16 @@ <property name="FLEX_HOME" value="${FLEXJS_HOME}"/> <property name="FALCON_HOME" value="${env.FALCON_HOME}"/> <property name="FALCONJX_HOME" value="${env.FALCONJX_HOME}"/> - <property name="gjslint" value="gjslint" /> - <property name="jshint" value="jshint" /> - <condition property="no.lint" value="true"> - <os family="windows"/> - </condition> - + <target name="main" depends="clean,compile,test" description="Clean build of GoogleMaps.swc"> </target> - - <target name="all" depends="main,compile-asjs,lint-js,test-js" description="Full build of GoogleMaps.swc"> + + <target name="all" depends="clean,compile-asjs,compile-extern-swc,copy-js,compile,test" description="Full build of GoogleMaps.swc"> </target> - + <target name="test" unless="is.jenkins"> <!-- no tests yet <ant dir="as/tests" /> - <ant dir="asjs/tests" /> - --> - </target> - - <target name="test-js" unless="is.jenkins"> - <!-- no tests yet - <ant dir="js/tests" /> --> </target> @@ -74,6 +62,8 @@ <echo message="Compiling libs/GoogleMaps.swc"/> <echo message="FLEX_HOME: ${FLEX_HOME}"/> <echo message="FALCON_HOME: ${FALCON_HOME}"/> + <!-- make JS output folder now so include-file doesn't error --> + <mkdir dir="${basedir}/js/out" /> <!-- Load the <compc> task. We can't do this at the <project> level --> <!-- because targets that run before flexTasks.jar gets built would fail. --> @@ -96,46 +86,80 @@ <load-config filename="compile-config.xml" /> <arg value="+playerglobal.version=${playerglobal.version}" /> <arg value="+env.AIR_HOME=${env.AIR_HOME}" /> + <arg value="-external-library-path+=${FALCONJX_HOME}/../externs/google_maps/out/bin/google_maps.swc" /> + <arg value="-define=COMPILE::AS3,true" /> + <arg value="-define=COMPILE::JS,false" /> </compc> </target> - <target name="compile-asjs" > - <!-- nothing to cross-compile yet --> + <target name="compile-asjs"> + <echo message="Cross-compiling GoogleMaps"/> + <echo message="FALCONJX_HOME: ${FALCONJX_HOME}"/> + <java jar="${FALCONJX_HOME}/lib/compc.jar" fork="true" > + <jvmarg value="-Xmx384m" /> + <jvmarg value="-Dsun.io.useCanonCaches=false" /> + <jvmarg value="-Dflexcompiler=${FALCONJX_HOME}/../compiler" /> + <jvmarg value="-Dflexlib=${FLEXJS_HOME}/frameworks" /> + <arg value="+flexlib=${FLEX_HOME}/frameworks" /> + <arg value="-js-output-type=FLEXJS" /> + <arg value="-keep-asdoc" /><!-- allows compiler to see @flexjsignorecoercion annotations --> + <arg value="-output=${basedir}/js/out" /> + <arg value="-load-config=${basedir}/compile-asjs-config.xml" /> + <arg value="+playerglobal.version=${playerglobal.version}" /> + <arg value="+env.PLAYERGLOBAL_HOME=${env.PLAYERGLOBAL_HOME}" /> + <arg value="+env.AIR_HOME=${env.AIR_HOME}" /> + <arg value="-external-library-path+=${FALCONJX_HOME}/../externs/js/out/bin/js.swc" /> + <arg value="-external-library-path+=${FALCONJX_HOME}/../externs/google_maps/out/bin/google_maps.swc" /> + <!-- this is not on external-library path otherwise goog.requires are not generated --> + <arg value="-library-path+=${FALCONJX_HOME}/../externs/GCL/out/bin/GCL.swc" /> + <arg value="-define=COMPILE::AS3,false" /> + <arg value="-define=COMPILE::JS,true" /> + </java> + </target> + + <target name="compile-extern-swc" description="Compiles .as files into .swc used for cross-compiling other projects"> + <echo message="Compiling externs/GoogleMaps.swc"/> + <echo message="FLEX_HOME: ${FLEX_HOME}"/> + <echo message="FALCON_HOME: ${FALCON_HOME}"/> + <!-- make JS output folder now so include-file doesn't error --> + <mkdir dir="${FLEXJS_HOME}/frameworks/externs"/> + + <!-- Load the <compc> task. We can't do this at the <project> level --> + <!-- because targets that run before flexTasks.jar gets built would fail. --> + <taskdef resource="flexTasks.tasks" classpathref="lib.path"/> + <!-- + Link in the classes (and their dependencies) for the MXML tags + listed in this project's manifest.xml. + Also link the additional classes (and their dependencies) + listed in CoreClasses.as, + because these aren't referenced by the manifest classes. + Keep the standard metadata when compiling. + Include the appropriate CSS files and assets in the SWC. + Don't include any resources in the SWC. + Write a bundle list of referenced resource bundles + into the file bundles.properties in this directory. + --> + <compc fork="true" + output="${FLEXJS_HOME}/frameworks/externs/GoogleMaps.swc"> + <jvmarg line="${compc.jvm.args}"/> + <load-config filename="compile-asjs-config.xml" /> + <arg value="+playerglobal.version=${playerglobal.version}" /> + <arg value="+env.AIR_HOME=${env.AIR_HOME}" /> + <arg value="-external-library-path+=${FALCONJX_HOME}/../externs/js/out/bin/js.swc" /> + <arg value="-external-library-path+=${FALCONJX_HOME}/../externs/google_maps/out/bin/google_maps.swc" /> + <!-- this is not on external-library path otherwise goog.requires are not generated --> + <arg value="-library-path+=${FALCONJX_HOME}/../externs/GCL/out/bin/GCL.swc" /> + <arg value="-define=COMPILE::AS3,false" /> + <arg value="-define=COMPILE::JS,true" /> + </compc> </target> - <target name="lint-js" depends="gjslint, jshint, copy-js" /> - <target name="copy-js" > + <target name="copy-js"> <copy todir="${FLEXJS_HOME}/frameworks/js/FlexJS/libs"> - <fileset dir="${basedir}/js/src"> - <include name="**/**" /> + <fileset dir="${basedir}/js/out"> + <include name="**/**"/> </fileset> </copy> </target> - <target name="gjslint" unless="no.lint"> - <echo>running gjslint</echo> - <exec executable="${gjslint}" dir="${basedir}" failonerror="true"> - <arg value="--strict" /> - <arg value="--disable" /> - <arg value="006,100,214,300" /> - <!-- 006: wrong indentation --> - <!-- 100: cannot have non-primitive value --> - <!-- 214: @fileoverview tag missing description --> - <!-- 300: missing newline at end of file --> - <arg value="--max_line_length" /> - <arg value="120" /> - <arg value="-r" /> - <arg value="${basedir}/js/src" /> - </exec> - </target> - - <target name="jshint" unless="no.lint"> - <echo>running jshint</echo> - <exec executable="${jshint}" dir="${basedir}" failonerror="true"> - <arg value="--config" /> - <arg value="${FLEX_HOME}/frameworks/js/jshint.properties" /> - <arg value="${basedir}/js/src" /> - </exec> - </target> - </project> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f427485/frameworks/projects/GoogleMaps/compile-asjs-config.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/GoogleMaps/compile-asjs-config.xml b/frameworks/projects/GoogleMaps/compile-asjs-config.xml new file mode 100644 index 0000000..eba22e4 --- /dev/null +++ b/frameworks/projects/GoogleMaps/compile-asjs-config.xml @@ -0,0 +1,70 @@ +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<flex-config> + + <compiler> + <accessible>false</accessible> + + <external-library-path> + <path-element>${env.AIR_HOME}/frameworks/libs/air/airglobal.swc</path-element> + </external-library-path> + + <mxml> + <children-as-data>true</children-as-data> + </mxml> + <binding-value-change-event>org.apache.flex.events.ValueChangeEvent</binding-value-change-event> + <binding-value-change-event-kind>org.apache.flex.events.ValueChangeEvent</binding-value-change-event-kind> + <binding-value-change-event-type>valueChange</binding-value-change-event-type> + + <keep-as3-metadata> + <name>Bindable</name> + <name>Managed</name> + <name>ChangeEvent</name> + <name>NonCommittingChangeEvent</name> + <name>Transient</name> + </keep-as3-metadata> + + <locale/> + + <library-path> + <!-- asjscompc won't 'link' these classes in, but will list their requires + if these swcs are on the external-library-path then their requires + will not be listed --> + <path-element>../../externs/Core.swc</path-element> + </library-path> + + <source-path> + <path-element>as/src</path-element> + </source-path> + + <warn-no-constructor>false</warn-no-constructor> + </compiler> + + <include-sources> + <path-element>as/src</path-element> + </include-sources> + + <include-namespaces> + <uri>library://ns.apache.org/flexjs/google</uri> + </include-namespaces> + + <target-player>${playerglobal.version}</target-player> + + +</flex-config> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f427485/frameworks/projects/GoogleMaps/compile-config.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/GoogleMaps/compile-config.xml b/frameworks/projects/GoogleMaps/compile-config.xml index 8017798..eb300fe 100644 --- a/frameworks/projects/GoogleMaps/compile-config.xml +++ b/frameworks/projects/GoogleMaps/compile-config.xml @@ -24,6 +24,7 @@ <external-library-path> <path-element>${env.AIR_HOME}/frameworks/libs/air/airglobal.swc</path-element> <path-element>../../libs/Core.swc</path-element> + <path-element>../../externs/GoogleMaps.swc</path-element> </external-library-path> <mxml> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f427485/frameworks/projects/GoogleMaps/google-manifest.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/GoogleMaps/google-manifest.xml b/frameworks/projects/GoogleMaps/google-manifest.xml index d32725f..f843c0c 100644 --- a/frameworks/projects/GoogleMaps/google-manifest.xml +++ b/frameworks/projects/GoogleMaps/google-manifest.xml @@ -20,5 +20,5 @@ <componentPackage> - <component id="Map" class="org.apache.flex.maps.google.Map" /> + <component id="Map" class="org.apache.flex.maps.google.GoogleMap" /> </componentPackage>
