Skip to content

Commit

Permalink
changes to custommapview to leverage MapData, DataProvider, GeoLocati…
Browse files Browse the repository at this point in the history
…on and Marker classes for displaying on map graphics representing locations

changes to icon's, replacing the general default icon
  • Loading branch information
asosnowski committed Apr 26, 2013
1 parent 000886f commit def955a
Show file tree
Hide file tree
Showing 35 changed files with 262 additions and 560 deletions.
Binary file modified bbmprofilebox/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified bluetoothgatt/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
139 changes: 36 additions & 103 deletions custommapview/assets/main.qml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
/* Copyright (c) 2012 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import bb.cascades 1.0
import QtMobility.sensors 1.2
import bb.cascades.maps 1.0
import QtMobilitySubset.location 1.1

// creates one page with a label

Page {
actions: [
//! [0]
Expand All @@ -27,15 +25,15 @@ Page {
imageSource: "asset:///images/pin.png"
ActionBar.placement: ActionBarPlacement.OnBar
onTriggered: {
pinContainer.addPin(mapview.latitude, mapview.longitude);
_mapViewTest.addPinAtCurrentMapCenter();
}
},
ActionItem {
title: qsTr("Remove Pins")
imageSource: "asset:///images/clearpin.png"
ActionBar.placement: ActionBarPlacement.OnBar
onTriggered: {
pinContainer.removeAll();
_mapViewTest.clearPins();
}
},
ActionItem {
Expand Down Expand Up @@ -73,6 +71,7 @@ Page {
//! [1]
MapView {
id: mapview
objectName: "mapViewObj"
altitude: 3000
latitude: 43.449488
longitude: -80.406777
Expand All @@ -96,8 +95,17 @@ Page {
onMapLongPressed: {
status.setText(qsTr("map long pressed"));
}
onRequestRender: {
pinContainer.updateMarkers();
onCreationCompleted: {
setCaptionGoButtonVisible(false);
}
onFollowedIdChanged: {
status.setText(qsTr("followed id changed to %1").arg(idOfFollowed));
}
onCaptionButtonClicked: {
status.setText(qsTr("%1 button clicked!").arg(focusedId));
}
onCaptionLabelTapped: {
status.setText(qsTr("%1 label clicked!").arg(focusedId));
}
}
//! [1]
Expand All @@ -107,7 +115,6 @@ Page {
topPadding: 20
leftPadding: 20
bottomPadding: 20

background: Color.create("#aaffffff");

//! [2]
Expand All @@ -132,6 +139,7 @@ Page {
verticalAlignment: VerticalAlignment.Bottom
ImageView {
id: compassImage
overlapTouchPolicy: OverlapTouchPolicy.Allow
imageSource: "asset:///images/compass.png"
horizontalAlignment: HorizontalAlignment.Center
attachedObjects: [
Expand All @@ -147,90 +155,20 @@ Page {
checked: true
onCheckedChanged: {
if (checked) {
pinContainer.showMe();
pinContainer.me.visible = false;
mapview.setFollowedId("device-location-id");
} else {
pinContainer.me.visible = false;
mapview.setFollowedId("");
}
}
onCreationCompleted: {
pinContainer.showMe();
pinContainer.me.visible = false;
mapview.setFollowedId("device-location-id");
}
}
}
//! [3]
//! [7]
Container {
id: pinContainer
// Must match the mapview width and height and position
preferredHeight: 1280
preferredWidth: 768
//touchPropagationMode: TouchPropagationMode.PassThrough
overlapTouchPolicy: OverlapTouchPolicy.Allow
property variant currentBubble
property variant me
layout: AbsoluteLayout {
}
function addPin(lat, lon) {
var marker = pin.createObject();
marker.lat = lat;
marker.lon = lon;
var xy = _mapViewTest.worldToPixelInvokable(mapview, marker.lat, marker.lon);
marker.x = xy[0];
marker.y = xy[1];
pinContainer.add(marker);
marker.animDrop.play();
}
function showBubble(pin) {
pinContainer.remove(currentBubble);
var details = bubble.createObject();
details.lat = pin.lat;
details.lon = pin.lon;
var xy = _mapViewTest.worldToPixelInvokable(mapview, details.lat, details.lon);
details.x = xy[0];
details.y = xy[1];
pinContainer.add(details);
details.play();
currentBubble = details;
}
function showMe() {
var marker = pin.createObject();
marker.pinImageSource = "asset:///images/me.png"
marker.pointerOffsetX = 30
marker.pointerOffsetY = 30
pinContainer.insert(-1, marker);
marker.visible = false;
me = marker;
}
function updateMarkers() {
_mapViewTest.updateMarkers(mapview, pinContainer);
}
function removeBubble() {
pinContainer.remove(currentBubble);
}
onTouch: {
if (event.isDown()) {
if ((event.localX <= currentBubble.actualX) || (event.localX >= currentBubble.actualX + currentBubble.contentWidth) || (event.localY <= currentBubble.actualY) || (event.localY >= currentBubble.actualY + currentBubble.contentHeight)) {
removeBubble();
}
}
}
}
//! [7]
}
attachedObjects: [
//! [5]
ComponentDefinition {
id: pin
source: "pin.qml"
},
ComponentDefinition {
id: bubble
source: "bubble.qml"
},
//! [5]
//! [6]
RotationSensor {
id: rotation
property real x: 0
Expand All @@ -244,7 +182,7 @@ Page {
}
}
},
//! [6]
//! [5]
//! [4]
Compass {
property double azimuth: 0
Expand All @@ -256,21 +194,16 @@ Page {
compassImage.rotationZ = 360 - reading.azimuth;
}
},
//! [4]
//! [6]
PositionSource {
id: positionSource
updateInterval: 1000
active: sensorToggle.checked
onPositionChanged: {
mapview.latitude = positionSource.position.coordinate.latitude;
mapview.longitude = positionSource.position.coordinate.longitude;
pinContainer.me.lat = positionSource.position.coordinate.latitude;
pinContainer.me.lon = positionSource.position.coordinate.longitude;
var xy = _mapViewTest.worldToPixelInvokable(mapview, pinContainer.me.lat, pinContainer.me.lon);
pinContainer.me.x = xy[0];
pinContainer.me.y = xy[1];
pinContainer.me.visible = true;
_mapViewTest.updateDeviceLocation(positionSource.position.coordinate.latitude, positionSource.position.coordinate.longitude);
}
}
//! [4]
//! [6]
]
}
2 changes: 1 addition & 1 deletion custommapview/custommapview.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
APP_NAME = custommapview

CONFIG += qt warn_on cascades10
LIBS += -lQtLocationSubset -lbbcascadesmaps -lGLESv1_CM
LIBS += -lQtLocationSubset -lbbcascadesmaps -lGLESv1_CM -lbb
include(config.pri)
Loading

0 comments on commit def955a

Please sign in to comment.