Sha256: 9d4b350fc7df5c9db88c21a72d8628e7189e19b0b3d23e7aa58017702c453b02

Contents?: true

Size: 1.85 KB

Versions: 32

Compression:

Stored size: 1.85 KB

Contents

Ext.define('Ext.ux.GoogleMapPanel', {
  extend: 'Ext.panel.Panel',
  alias: 'widget.googlemappanel',
  initComponent : function(){
    var defConfig = {
      plain: true,
      zoomLevel: 3,
      yaw: 180,
      pitch: 0,
      zoom: 0,
      mapType:'hybrid'
    };

    this.googleMapTypes = {
      'hybrid':google.maps.MapTypeId.HYBRID,
      'satellite':google.maps.MapTypeId.SATELLITE,
      'terrain':google.maps.MapTypeId.TERRAIN,
      'roadmap':google.maps.MapTypeId.ROADMAP
    };

    Ext.applyIf(this,defConfig);

    this.callParent(arguments);
  },

  afterRender : function(){

    var wh = this.ownerCt.getSize();

    Ext.applyIf(this, wh);

    this.callParent();

    this.gmap = new google.maps.Map(this.body.dom,{
      zoom:this.zoomLevel,
      mapTypeId:this.googleMapTypes[this.mapType]
    });

    this.onMapReady();

  },
  onMapReady : function(){
    this.addDropPins(this.dropPins);
  },
  getMap : function(){

    return this.gmap;

  },
  getCenter : function(){

    return this.getMap().getCenter();

  },
  addDropPins : function(dropPins) {

    if (Ext.isArray(dropPins)){
      for (var i = 0; i < dropPins.length; i++) {
        this.addDropPin(dropPins[i]);
      }
    }

  },
  addDropPin : function(dropPin) {
    var self = this;
    this.geocoder = new google.maps.Geocoder();
    this.geocoder.geocode({
      'address': dropPin.address
    },function(results, status) {
      if (status != google.maps.GeocoderStatus.OK) {
        Ext.MessageBox.alert('Error', 'Code '+status+' Error Returned');
      }else{
        if(dropPin['center'])
          self.getMap().setCenter(results[0].geometry.location);

        new google.maps.Marker({
          map: self.getMap(),
          animation: google.maps.Animation.DROP,
          position: results[0].geometry.location,
          title:dropPin['title']
        });
      }

    } );
  }
});

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
erp_app-3.1.16 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.1.15 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.1.14 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.1.13 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.1.12 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.1.11 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.1.10 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.1.9 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.1.8 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.1.7 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.1.6 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.1.5 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.1.4 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.1.3 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.1.2 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.0.16 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.0.15 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.1.1 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.1.0 public/javascripts/erp_app/shared/google_map_panel.js
erp_app-3.0.14 public/javascripts/erp_app/shared/google_map_panel.js