1. #1
    Sencha User Olivierco's Avatar
    Join Date
    Nov 2011
    Location
    Paris - France
    Posts
    65
    Answers
    3
    Vote Rating
    -1
    Olivierco is an unknown quantity at this point

      0  

    Default Unanswered: Interact with map and button

    Unanswered: Interact with map and button


    Hi,

    this is my problem:
    i have a map center on a special marker, then a have 4 buttons which must interact with the map for showing others makers by clicking on those buttons.

    here the code of map
    Code:
    Ext.define('Sofa.view.Carte', {
        extend: 'Ext.Map',
    	xtype: 'carte',
    	config : {
    			mapOptions : {
    				id: 'google-map-id',
    	            zoom: 15,
    				center: new google.maps.LatLng(48.855976,2.371341),
    				mapTypeId: google.maps.MapTypeId.ROADMAP,
    				streetViewControl: true,
    				streetViewControlOptions: {
    				        position: google.maps.ControlPosition.RIGHT_BOTTOM
    				    },
    				zoomControl: true,
    				zoomControlOptions: {
    				      style: google.maps.ZoomControlStyle.LARGE
    				    },
    				mapTypeControl: false,
    				
    	        },
    			listeners: {
    	            maprender : function(comp, map){
    	                var marker = new google.maps.Marker({
    	                     position: position,
    						 animation: google.maps.Animation.DROP,
    	                     title : 'Le Sofa Restaurant',
    	                     map: map
    	                });
    	                infowindow.open(map, marker);
    	                google.maps.event.addListener(marker, 'click', function() {
     						infowindow.open(map, marker);
    	                });
    	            }
    	        }
    		}
    });
    var infowindow = new google.maps.InfoWindow({
        content: '<img style="float:left; width:100px; height:60px; margin-right: 5px; margin-bottom: 15px;" src="http://photos.cityvox.com/photos_crop/134/204/445574_190x125_.jpg" >'+
     			 '<div style="font-size: 12px;"><p style="color: red";>' +
    			 'Le Sofa<br/>Bar-Restaurant</p><br/>21, rue Saint-Sabin,'+
    			 '<br/>Paris 75011<br/> <a href="tel:01 43 14 07 46">Tél: 01 43 14 07 46</a>'
    });
    
    
    var position = new google.maps.LatLng(48.855976,2.371341);
    here the code of my buttons
    Code:
    Ext.define('Sofa.view.Plan', {
        extend: 'Ext.Container',
        xtype: 'plan',
        requires: [
            'Sofa.view.Carte'
        ],
    
    
        config: {
    	title: 'Plan',
        iconCls: 'maps',
    	layout: 'fit',
            items: [
    		{
    			xtype: 'titlebar',
    			docked: 'top',
    			title: 'Plan',
    			defaults: {xtype: 'button'},
    			items: [{
    				iconCls: 'compass',
    				ui: 'plain',
    				iconMask: true,
    				align: 'left'
    			},{
    				iconCls: 'locate',
    				ui: 'plain',
    				iconMask: true,
    				align: 'right',
    			}]
    		},
    		{
                xtype: 'carte'
            },
    		{
    			xtype: 'toolbar',
    			docked: 'bottom',
    			defaults: {xtype: 'button'},
    			items: [{
    				iconCls: 'train',
    				ui: 'plain-round',
    				iconMask: true,
    				text: 'Les Métros',
    				badgeText: '4',
    				action: 'pingMetroIcone',
    			},{
    				xtype: 'spacer'
    			},{
    				iconCls: 'star',
    				ui: 'plain-round',
    				iconMask: true,
    				text: 'Les Vélibs',
    				badgeText: '10'
    			}]
    		}]
        }
    });
    and then my controller
    Code:
    Ext.define('Sofa.controller.Main', {
        extend: 'Ext.app.Controller',
    
    
        config: {
            refs: {
                main: 'menu',
    			metroButton: 'button[action=pingMetroIcone]',
    			positionButton: 'button[action=positionButton]',
            },
            control: {
                'presidentlist': {
                    disclose: 'showDetail'
                },
    			metroButton: {
    				tap: 'drop'
    			},
    			positionButton: {
    				tap: 'position'
    			}
            }
        },
    	position: function(monmarker){
    		//TODO: fonction pour se positionner sur sa position en cours.
    
    
    		var monmarker = new google.maps.Marker({
                 position: maposition,
    			 animation: google.maps.Animation.DROP,
    			 icon: imageMetro,
                 map: map
            });
    	},
        showDetail: function(list, record) {
            this.getMain().push({
                xtype: 'presidentdetail',
                title: record.fullName(),
                data: record.getData()
            })
        },
    	// DEBUT
    	drop: function(){
    		//TODO: trouver la solution pour afficher les points
    		this.control({
    			'button':{
    			maprender: function(extMapComponent, map){
    					markers.push(new google.maps.Marker({
    					position: metros[iterator],
    					map: Sofa.view.Carte.getComponent('google-map-id').map,
    					draggable: false,
    					icon: imageMetro,
    					animation: google.maps.Animation.DROP
    				}));
    				iterator++;
    				}
    			}
    		})
    	}
    	// FIN
    })
    var geo = Ext.create('Ext.util.Geolocation', {
        autoUpdate: false,
    });
    geo.updateLocation();
    var maposition = new google.maps.LatLng(geo.getLatitude(), geo.getLongitude())
    var imageMetro = 'touch/images/marker.png';
    var metros = new google.maps.LatLng(48.856682,2.370579);
      //new google.maps.LatLng(48.853082,2.369034)
    
    
    var markers = [];
    var iterator = 0;
    When i click my button "les métro" with the action: action: 'pingMetroIcone' nothing...

    any help please

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,118
    Answers
    3504
    Vote Rating
    855
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Couple issues I see is that you are using the google namespace where the google maps JS file may not be downloaded. You are creating object outside of the class definitions when they should be within the class definition
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User Olivierco's Avatar
    Join Date
    Nov 2011
    Location
    Paris - France
    Posts
    65
    Answers
    3
    Vote Rating
    -1
    Olivierco is an unknown quantity at this point

      0  

    Default


    Hi,

    Thank you for your reply,

    can you be a little bit more explicit please?
    what do you mean by:
    I see is that you are using the google namespace where the google maps JS file may not be downloaded.

    Sofa.view.Carte = Ext.Map that contains my map configs
    Sofa.view.Plan = Ext.Container that contains My Buttons + my map
    Sofa.controller.Main = Ext.app.Controller that contains my functions

    you suggest to merge Sofa.view.Carte + Sofa.view.Plan that it?



  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,118
    Answers
    3504
    Vote Rating
    855
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Within the mapOptions of your Sofa.view.Carte class you use the google namespace. The <script> isn't going to be downloaded by then and that instance is going to be shared among all instances.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User Olivierco's Avatar
    Join Date
    Nov 2011
    Location
    Paris - France
    Posts
    65
    Answers
    3
    Vote Rating
    -1
    Olivierco is an unknown quantity at this point

      0  

    Default


    i understand now, so what do you suggest exactly?

  6. #6
    Sencha User Olivierco's Avatar
    Join Date
    Nov 2011
    Location
    Paris - France
    Posts
    65
    Answers
    3
    Vote Rating
    -1
    Olivierco is an unknown quantity at this point

      0  

    Default All my map in one file

    All my map in one file


    Now i have all in one file see my code above:
    But when i click stille nothing...

    any suggestions?

    Code:
    Ext.define('Sofa.view.Carte', {    extend: 'Ext.Container',
    	xtype: 'carte',
    	
    config : {
    		title: 'Plan',
        	iconCls: 'maps',
    		fullscree: true,
    		layout: 'fit',
        	items: [{
    			xtype: 'titlebar',
    			docked: 'top',
    			title: 'Plan',
    			defaults: {xtype: 'button'},
    			items: [{
    				iconCls: 'compass',
    				ui: 'plain',
    				iconMask: true,
    				align: 'left'
    				},{
    				iconCls: 'locate',
    				ui: 'plain',
    				iconMask: true,
    				align: 'right',
    				//action: 'positionButton' // Handler sur ce boutton?
    					handler : function(){
    						var monmarker = new google.maps.Marker({
    				             position: maposition,
    							 animation: google.maps.Animation.DROP,
    							 icon: imageMetro,
    				             map: map
    				        });	
    					}
    			}]
    			},{
    			xtype: 'toolbar',
    				docked: 'bottom',
    				defaults: {xtype: 'button'},
    				items: [{
    					iconCls: 'train',
    					ui: 'plain-round',
    					iconMask: true,
    					text: 'Les Métros',
    					badgeText: '4',
    					handler : function(map){
    						markers.push(new google.maps.Marker({
    						      position: metros,
    						      draggable: false,
    							  icon: imageMetro,
    						      animation: google.maps.Animation.DROP
    						    }));
    						}
    				},{
    					xtype: 'spacer'
    				},{
    					iconCls: 'star',
    					ui: 'plain-round',
    					iconMask: true,
    					text: 'Les Vélibs',
    					badgeText: '10'
    				}]
    			},
    			{
    				xtype: 'map',
    				mapOptions : {
    					id: 'google-map-id',
    		            zoom: 15,
    					center: new google.maps.LatLng(48.855976,2.371341),
    					mapTypeId: google.maps.MapTypeId.ROADMAP,
    					streetViewControl: true,
    					streetViewControlOptions: {
    					        position: google.maps.ControlPosition.RIGHT_BOTTOM
    					    },
    					zoomControl: true,
    					zoomControlOptions: {
    					      style: google.maps.ZoomControlStyle.LARGE
    					    },
    					mapTypeControl: false,
    
    
    		        },
    				listeners: {
    		            maprender : function(comp, map){
    		                var marker = new google.maps.Marker({
    		                     position: position,
    							 animation: google.maps.Animation.DROP,
    		                     title : 'Le Sofa Restaurant',
    		                     map: map
    		                });
    		                infowindow.open(map, marker);
    		                google.maps.event.addListener(marker, 'click', function() {
    	 						infowindow.open(map, marker);
    		                });
    		            }
    		        },
    			}]
    }
    });
    
    
    var metros = new google.maps.LatLng(48.856682,2.370579);
      //new google.maps.LatLng(48.853082,2.369034)
    
    
    var markers = [];
    var iterator = 0;
    
    
    var geo = Ext.create('Ext.util.Geolocation', {
        autoUpdate: true,
    });
    geo.updateLocation();
    var maposition = new google.maps.LatLng(geo.getLatitude(), geo.getLongitude());
    var infowindow = new google.maps.InfoWindow({
        content: '<img style="float:left; width:100px; height:60px; margin-right: 5px; margin-bottom: 15px;" src="http://photos.cityvox.com/photos_crop/134/204/445574_190x125_.jpg" >'+
     			 '<div style="font-size: 12px;"><p style="color: red";>' +
    			 'Le Sofa<br/>Bar-Restaurant</p><br/>21, rue Saint-Sabin,'+
    			 '<br/>Paris 75011<br/> <a href="tel:01 43 14 07 46">Tél: 01 43 14 07 46</a>'
    });
    
    
    var position = new google.maps.LatLng(48.855976,2.371341);

  7. #7
    Sencha User Olivierco's Avatar
    Join Date
    Nov 2011
    Location
    Paris - France
    Posts
    65
    Answers
    3
    Vote Rating
    -1
    Olivierco is an unknown quantity at this point

      0  

    Default ??

    ??


    Any help?

Thread Participants: 1