为什么extjs中的地理位置无法获得移动设备的当前位置?

时间:2016-09-26 04:32:31

标签: javascript geolocation

亲爱的,我想,我可以获得当前位置的网络凉亭,但是当真正的设备测试时,如手机没有获得当前位置,希望亲爱的所有人都能解决问题并帮助我解决问题
                        xtype:'map',                         标题: 'CurrentLocation',                         iconCls:'fa fa-location-arrow',                         布局:{type:'fit'},                        // iconCls:'home',                         mapOptions:{                             zoom:17,                             的mapTypeId:google.maps.MapTypeId.ROADMAP,                             disableDefaultUI:false,                             zoomControl:true,                             scrollwheel:是的,                             mapTypeControl:true,                             navigationControl:true,                             navigationControlOptions:{style:google.maps.NavigationControlStyle.SMALL}

                        ,mapTypeControlOptions: {
                              style: google.maps.MapTypeControlStyle.DROPDOWN_MENU, mapTypeIds: [
                                 google.maps.MapTypeId.ROADMAP,
                                 google.maps.MapTypeId.TERRAIN,
                                 google.maps.MapTypeId.SATELLITE 
                              ]
                          }

                    },

                    useCurrentLocation  : true,
                    listeners           : {
                    maprender: function(comp, map){
                    var marker = new google.maps.Marker({
                        position    : new google.maps.LatLng( ),
                        visible: true,
                        //map: map,
                        //draggable:true,
                        //icon:'resources/3.png',
                        animation:google.maps.Animation.Drop
                    }),
                    infowindow = new google.maps.InfoWindow({
                        content     : 'Your CurrentLocation'
                    }),
                    route = [ ],
                    geo = Ext.create('Ext.util.Geolocation', {
                        frequency         : 3000,
                        autoUpdate        : true,
                        allowHighAccuracy : true,
                        listeners         : {
                           /*initialize :function(geo) {
                                latitude=Global.currentUserLocations.currentLat;
                                longitude=Global.currentUserLocations.currentLong;
                                if(Global.currentUserPositionMarker)
                                {
                                    latlng1=new google.maps.LatLng(latitude, longitude);
                                    Global.currentUserPositionMarker.setPosition(latlng1);
                                }
                               }*/
                            locationupdate : function(geo) {
                                polyline = new google.maps.Polyline({
                                    //console.info('polyline',polyline)
                                    path : route,
                                        strokeColor: '#2FCEE2',
                                        strokeOpacity: 0.1,
                                        strokeWeight: 100,
                                        fillColor: 'red',
                                        fillOpacity: 1,
                                        //map: map,

                                });
                                polyline.setMap(map),

                                //alert(route);
                                route.push( new google.maps.LatLng( geo.getLatitude(),geo.getLongitude() ) );

                                marker.setPosition(new google.maps.LatLng( geo.getLatitude(),geo.getLongitude() ) );

                                google.maps.event.addListener(marker, 'click', function() {
                                     infowindow.open(map, marker);

                                });

                            }
                            // ,locationerror: function(geo, bTimeout, bPermissionDenied, bLocationUnavailable, message) {
                            //     if(bTimeout){
                            //         alert('Timeout occurred.');
                            //     } else {l
                            //         alert('Error occurred.');
                            //     }
                            // }
                        } 
                    });
                    geo.updateLocation();

                    }
                 }
                }

0 个答案:

没有答案