~ubuntu-branches/ubuntu/vivid/gnome-maps/vivid-proposed

« back to all changes in this revision

Viewing changes to src/mapView.js

  • Committer: Package Import Robot
  • Author(s): Andreas Henriksson
  • Date: 2014-07-15 00:14:59 UTC
  • mfrom: (1.1.2) (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20140715001459-dycqbixlde0y595l
Tags: 3.12.2-1
* New upstream release.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
const Signals = imports.signals;
35
35
 
36
36
const Application = imports.application;
37
 
const ZoomControl = imports.zoomControl;
38
37
const Sidebar = imports.sidebar;
39
38
const Utils = imports.utils;
40
39
const Path = imports.path;
50
49
    TRANSIT: Champlain.MAP_SOURCE_OSM_TRANSPORT_MAP
51
50
};
52
51
 
 
52
const MapMinZoom = 2;
 
53
 
53
54
const MapView = new Lang.Class({
54
55
    Name: 'MapView',
55
56
    Extends: GtkChamplain.Embed,
56
57
 
57
 
    _init: function(overlay) {
 
58
    _init: function() {
58
59
        this.parent();
59
60
 
60
61
        this.actor = this.get_view();
61
62
        this.view = this.actor;
62
63
        this.view.set_zoom_level(3);
63
 
        this.view.goto_animation_mode = Clutter.AnimationMode.LINEAR;
 
64
        this.view.min_zoom_level = MapMinZoom;
 
65
        this.view.goto_animation_mode = Clutter.AnimationMode.EASE_IN_OUT_CUBIC;
64
66
        this.view.set_reactive(true);
65
67
 
66
68
        this.view.connect('notify::latitude', this._onViewMoved.bind(this));
78
80
        this._userLocationLayer.set_selection_mode(Champlain.SelectionMode.SINGLE);
79
81
        this.view.add_layer(this._userLocationLayer);
80
82
 
 
83
        // switching map type will set view min-zoom-level from map source
 
84
        this.view.connect('notify::min-zoom-level', (function() {
 
85
            if (this.view.min_zoom_level < MapMinZoom) {
 
86
                this.view.min_zoom_level = MapMinZoom;
 
87
            }
 
88
        }).bind(this));
 
89
 
81
90
        this._factory = Champlain.MapSourceFactory.dup_default();
82
91
        this.setMapType(MapType.STREET);
83
92
 
84
 
        this._zoomControl = new ZoomControl.ZoomControl(this);
85
 
        overlay.add_overlay(this._zoomControl);
86
93
 
87
94
        this.geoclue = new Geoclue.Geoclue();
88
95
        this._updateUserLocation();
98
105
    geocodeSearch: function(searchString, searchCompleteCallback) {
99
106
        let forward = Geocode.Forward.new_for_string(searchString);
100
107
        let places = [];
101
 
        let answerCount =
102
 
            Application.settings.get_value('max-search-results').get_int32();
 
108
        let answerCount = Application.settings.get('max-search-results');
 
109
        let bbox = this.view.get_bounding_box();
103
110
 
 
111
        forward.search_area = new Geocode.BoundingBox({
 
112
            top: bbox.top,
 
113
            left: bbox.left,
 
114
            bottom: bbox.bottom,
 
115
            right: bbox.right
 
116
        });
 
117
        forward.bounded = false;
104
118
        forward.set_answer_count(answerCount);
105
119
        forward.search_async (null, (function(forward, res) {
106
120
            try {
112
126
        }).bind(this));
113
127
    },
114
128
 
115
 
    ensureVisible: function(locations) {
 
129
    ensureLocationsVisible: function(locations) {
116
130
        let bbox = new Champlain.BoundingBox({ left:   180,
117
131
                                               right: -180,
118
132
                                               bottom:  90,
145
159
        if (!this.geoclue.location)
146
160
            return;
147
161
 
148
 
        this._userLocation = new UserLocation.UserLocation(this.geoclue.location, this);
 
162
        let place = Geocode.Place.new_with_location(this.geoclue.location.description,
 
163
                                                    Geocode.PlaceType.UNKNOWN,
 
164
                                                    this.geoclue.location);
 
165
 
 
166
        this._userLocation = new UserLocation.UserLocation(place, this);
149
167
        this._userLocation.show(this._userLocationLayer);
150
168
        this.emit('user-location-changed');
151
169
    },
152
170
 
153
 
    showLocation: function(location) {
 
171
    showLocation: function(place) {
154
172
        this._markerLayer.remove_all();
155
 
        let mapLocation = new MapLocation.MapLocation(location, this);
 
173
        let mapLocation = new MapLocation.MapLocation(place, this);
156
174
 
157
175
        mapLocation.show(this._markerLayer);
158
176
 
159
177
        return mapLocation;
160
178
    },
161
179
 
162
 
    showNGotoLocation: function(location) {
163
 
        let mapLocation = this.showLocation(location);
 
180
    showNGotoLocation: function(place) {
 
181
        let mapLocation = this.showLocation(place);
164
182
        mapLocation.goTo(true);
165
183
    },
166
184