Sencha touch 2 - Display current location on map

后端 未结 4 555
难免孤独
难免孤独 2021-01-07 06:27

I want to display my current location and get location coordinates to search nearby. Starting with the code below to display my location on the map, but its not working.

4条回答
  •  太阳男子
    2021-01-07 06:39

    I defined a custom map class:

    Ext.define("FindMyMoney.view.MapView", {
        extend: "Ext.Map",
        xtype: 'mapview',
        config: {
            useCurrentLocation: true,
            listeners: {
                maprender : function(comp, map){
                    new google.maps.Marker({
                        position: new google.maps.LatLng(this._geo.getLatitude(), this._geo.getLongitude()),
                        map: map
                    });
                }
            }
        }
    });
    

    So it would render a marker on my current position. Simple.

提交回复
热议问题