X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..HEAD:/examples/ux/GMapPanel.js diff --git a/examples/ux/GMapPanel.js b/examples/ux/GMapPanel.js index f97280b2..04b5e71e 100644 --- a/examples/ux/GMapPanel.js +++ b/examples/ux/GMapPanel.js @@ -1,215 +1,232 @@ -/*! - * Ext JS Library 3.0.0 - * Copyright(c) 2006-2009 Ext JS, LLC - * licensing@extjs.com - * http://www.extjs.com/license +/* + +This file is part of Ext JS 4 + +Copyright (c) 2011 Sencha Inc + +Contact: http://www.sencha.com/contact + +GNU General Public License Usage +This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. + +If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact. + +*/ +/** + * @class Ext.ux.GMapPanel + * @extends Ext.Panel + * @author Shea Frederick */ -/** - * @class Ext.ux.GMapPanel - * @extends Ext.Panel - * @author Shea Frederick - */ -Ext.ux.GMapPanel = Ext.extend(Ext.Panel, { - initComponent : function(){ - - var defConfig = { - plain: true, - zoomLevel: 3, - yaw: 180, - pitch: 0, - zoom: 0, - gmapType: 'map', - border: false - }; - - Ext.applyIf(this,defConfig); - - Ext.ux.GMapPanel.superclass.initComponent.call(this); - - }, - afterRender : function(){ - - var wh = this.ownerCt.getSize(); - Ext.applyIf(this, wh); - - Ext.ux.GMapPanel.superclass.afterRender.call(this); - - if (this.gmapType === 'map'){ - this.gmap = new GMap2(this.body.dom); - } - - if (this.gmapType === 'panorama'){ - this.gmap = new GStreetviewPanorama(this.body.dom); - } - - if (typeof this.addControl == 'object' && this.gmapType === 'map') { - this.gmap.addControl(this.addControl); - } - - if (typeof this.setCenter === 'object') { - if (typeof this.setCenter.geoCodeAddr === 'string'){ - this.geoCodeLookup(this.setCenter.geoCodeAddr); - }else{ - if (this.gmapType === 'map'){ - var point = new GLatLng(this.setCenter.lat,this.setCenter.lng); - this.gmap.setCenter(point, this.zoomLevel); - } - if (typeof this.setCenter.marker === 'object' && typeof point === 'object'){ - this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear); - } - } - if (this.gmapType === 'panorama'){ - this.gmap.setLocationAndPOV(new GLatLng(this.setCenter.lat,this.setCenter.lng), {yaw: this.yaw, pitch: this.pitch, zoom: this.zoom}); - } - } - - GEvent.bind(this.gmap, 'load', this, function(){ - this.onMapReady(); - }); - - }, - onMapReady : function(){ - this.addMarkers(this.markers); - this.addMapControls(); - this.addOptions(); - }, - onResize : function(w, h){ - - if (typeof this.getMap() == 'object') { - this.gmap.checkResize(); - } - - Ext.ux.GMapPanel.superclass.onResize.call(this, w, h); - - }, - setSize : function(width, height, animate){ - - if (typeof this.getMap() == 'object') { - this.gmap.checkResize(); - } - - Ext.ux.GMapPanel.superclass.setSize.call(this, width, height, animate); - - }, - getMap : function(){ - - return this.gmap; - - }, - getCenter : function(){ - - return this.getMap().getCenter(); - - }, - getCenterLatLng : function(){ - - var ll = this.getCenter(); - return {lat: ll.lat(), lng: ll.lng()}; - - }, - addMarkers : function(markers) { - - if (Ext.isArray(markers)){ - for (var i = 0; i < markers.length; i++) { - var mkr_point = new GLatLng(markers[i].lat,markers[i].lng); - this.addMarker(mkr_point,markers[i].marker,false,markers[i].setCenter, markers[i].listeners); - } - } - - }, - addMarker : function(point, marker, clear, center, listeners){ - - Ext.applyIf(marker,G_DEFAULT_ICON); - - if (clear === true){ - this.getMap().clearOverlays(); - } - if (center === true) { - this.getMap().setCenter(point, this.zoomLevel); - } - - var mark = new GMarker(point,marker); - if (typeof listeners === 'object'){ - for (evt in listeners) { - GEvent.bind(mark, evt, this, listeners[evt]); - } - } - this.getMap().addOverlay(mark); - - }, - addMapControls : function(){ - - if (this.gmapType === 'map') { - if (Ext.isArray(this.mapControls)) { - for(i=0;i
Level '+accuracy+' Accuracy (8 = Exact Match, 1 = Vague Match)'); - }else{ - point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); - if (typeof this.setCenter.marker === 'object' && typeof point === 'object'){ - this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear,true, this.setCenter.listeners); - } - } - } - } - - } - -}); - -Ext.reg('gmappanel', Ext.ux.GMapPanel); \ No newline at end of file +Ext.define('Ext.ux.GMapPanel', { + extend: 'Ext.Panel', + + alias: 'widget.gmappanel', + + requires: ['Ext.window.MessageBox'], + + initComponent : function(){ + + var defConfig = { + plain: true, + zoomLevel: 3, + yaw: 180, + pitch: 0, + zoom: 0, + gmapType: 'map', + border: false + }; + + Ext.applyIf(this,defConfig); + + this.callParent(); + }, + + afterRender : function(){ + + var wh = this.ownerCt.getSize(), + point; + + Ext.applyIf(this, wh); + + this.callParent(); + + if (this.gmapType === 'map'){ + this.gmap = new GMap2(this.body.dom); + } + + if (this.gmapType === 'panorama'){ + this.gmap = new GStreetviewPanorama(this.body.dom); + } + + if (typeof this.addControl == 'object' && this.gmapType === 'map') { + this.gmap.addControl(this.addControl); + } + + if (typeof this.setCenter === 'object') { + if (typeof this.setCenter.geoCodeAddr === 'string'){ + this.geoCodeLookup(this.setCenter.geoCodeAddr); + }else{ + if (this.gmapType === 'map'){ + point = new GLatLng(this.setCenter.lat,this.setCenter.lng); + this.gmap.setCenter(point, this.zoomLevel); + } + if (typeof this.setCenter.marker === 'object' && typeof point === 'object'){ + this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear); + } + } + if (this.gmapType === 'panorama'){ + this.gmap.setLocationAndPOV(new GLatLng(this.setCenter.lat,this.setCenter.lng), {yaw: this.yaw, pitch: this.pitch, zoom: this.zoom}); + } + } + + GEvent.bind(this.gmap, 'load', this, function(){ + this.onMapReady(); + }); + + }, + onMapReady : function(){ + this.addMarkers(this.markers); + this.addMapControls(); + this.addOptions(); + }, + afterComponentLayout : function(w, h){ + + if (typeof this.getMap() == 'object') { + this.gmap.checkResize(); + } + + this.callParent(arguments); + + }, + setSize : function(width, height, animate){ + + if (typeof this.getMap() == 'object') { + this.gmap.checkResize(); + } + + this.callParent(arguments); + + }, + getMap : function(){ + + return this.gmap; + + }, + getCenter : function(){ + + return this.getMap().getCenter(); + + }, + getCenterLatLng : function(){ + + var ll = this.getCenter(); + return {lat: ll.lat(), lng: ll.lng()}; + + }, + addMarkers : function(markers) { + + if (Ext.isArray(markers)){ + for (var i = 0; i < markers.length; i++) { + var mkr_point = new GLatLng(markers[i].lat,markers[i].lng); + this.addMarker(mkr_point,markers[i].marker,false,markers[i].setCenter, markers[i].listeners); + } + } + + }, + addMarker : function(point, marker, clear, center, listeners){ + var evt; + Ext.applyIf(marker,G_DEFAULT_ICON); + + if (clear === true){ + this.getMap().clearOverlays(); + } + if (center === true) { + this.getMap().setCenter(point, this.zoomLevel); + } + + var mark = new GMarker(point,marker); + if (typeof listeners === 'object'){ + for (evt in listeners) { + if (!listeners.hasOwnProperty(evt)) { + continue; + } + GEvent.bind(mark, evt, this, listeners[evt]); + } + } + this.getMap().addOverlay(mark); + + }, + addMapControls : function(){ + + if (this.gmapType === 'map') { + if (Ext.isArray(this.mapControls)) { + for(var i=0;i
Level '+accuracy+' Accuracy (8 = Exact Match, 1 = Vague Match)'); + }else{ + point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]); + if (typeof this.setCenter.marker === 'object' && typeof point === 'object'){ + this.addMarker(point,this.setCenter.marker,this.setCenter.marker.clear,true, this.setCenter.listeners); + } + } + } + } + + } + +}); +