Ext.define('demo.view.Map', { extend: 'Ext.Map', alias: 'widget.map', config: { listeners: [ { fn: 'onMapMaprender', event: 'maprender' } ] }, onMapMaprender: function(map, gmap, options) { //北京偏移量 var xOffset= 0.001381939; var yOffset= 0.006142259; var neighborhoods = [ // new google.maps.LatLng(52.511467+ xOffset , 13.447179+yOffset), ]; var pos; if(navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { pos = new google.maps.LatLng(position.coords.latitude+xOffset, position.coords.longitude+yOffset); var centerMarker= new google.maps.Marker({ position: pos, map: gmap, draggable: false, animation: google.maps.Animation.DROP }); google.maps.event.addListener(centerMarker, "click", function() { var infowindow = new google.maps.InfoWindow({ map: gmap, position: pos, content: '你当前的位置' }); //infoWindow.open(this.getMap(), mymarker); }); var populationOptions = { strokeColor: "#FF0000", strokeOpacity: 0.8, strokeWeight: 2, fillColor: "#FF0000", fillOpacity: 0.35, map: gmap, center: pos, radius: 100 }; var cityCircle = new google.maps.Circle(populationOptions); gmap.setCenter(pos); // //导航路线 // var Target= new google.maps.LatLng(37.37015718405753, 114.609375); // var directionsService = new google.maps.DirectionsService(); // var directionsDisplay = new google.maps.DirectionsRenderer(); // directionsDisplay.setMap(gmap); // var request = { // origin:pos, // destination:Target, // travelMode: google.maps.DirectionsTravelMode.DRIVING // }; // directionsService.route(request, function(result, status) { // if (status == google.maps.DirectionsStatus.OK) { // directionsDisplay.setDirections(result); // } // }); }); } for (var i = 0; i < neighborhoods.length; i++) { var m = neighborhoods[i]; var mymarker= new google.maps.Marker({ position: m, map: gmap, draggable: false, animation: google.maps.Animation.DROP }); google.maps.event.addListener(mymarker, "click", function() { var infoWindow = new google.maps.InfoWindow(); infoWindow.setContent('test'); infoWindow.open(this.getMap(), mymarker); }); } }, }); Ext.define('demo.view.override.Map', { requires: 'demo.view.Map', }, function() { Ext.override(demo.view.Map, { config: { mapOptions: { //center: new google.maps.LatLng(23.0999442125314, 113.203125), zoom: 14, } } }); });