SlideShare a Scribd company logo
Geolocation and Mapping in PhoneGap applications
Geolocation and Mapping in PhoneGap applications
•
•
Geolocation and Mapping in PhoneGap applications
Geolocation and Mapping in PhoneGap applications
Geolocation and Mapping in PhoneGap applications
navigator.geolocation
•
•
•
•
•
geolocation
•
•
•
getCurrentPosition(win, [fail], [options]);
var id = watchPosition(win, [fail], [options]);
clearWatch(watchID);
•
–
•
–
•
–
•
–
getCurrentPosition watchPosition
Coordinates
Position
•
–
•
–
•
–
•
–
•
–
•
–
•
–
PositionError.PERMISSION_DENIED
PositionError.POSITION_UNAVAILABLE
PositionError.TIMEOUT
var options = { maximumAge: 3000, timeout: 5000,
enableHighAccuracy: true };
navigator.geolocation.watchPosition(win, fail, options);
function win(pos) {
var el = „<div>Latitude: „ + pos.coords.latitude + '</div>');
el += „<div>Longitude: „ + pos.coords.longitude + '</div>');
el += „<div>timestamp: „ + pos.timestamp + '</div>');
$(„#block‟).html(el);
}
function fail(err) {
console.log(err.code);
}
Geolocation and Mapping in PhoneGap applications
Geolocation and Mapping in PhoneGap applications
Geolocation and Mapping in PhoneGap applications
google.maps.Map
google.maps.Map(htmlElement, options);
•
–
• <div id=“map”></div>
•
–
•
–
•
–
•
–
–
•
–
•
–
•
–
•
–
•
•
•
new google.maps.LatLng(42.3606,13.3772);
•
•
var pt = new google.maps.LatLngBounds(
new google.maps.LatLng(57.8, 14.0),
new google.maps.LatLng(57.8, 14.0)
);
contains(pt), intersect(bounds), getCenter(),
union(bounds), etc.
mapTypeId: google.maps.MapTypeId.ROADMAP
• ROADMAP
• SATELLITE
• HYBRID
• TERRAIN
// in your JS file
var options = {
center: new google.maps.LatLng(-34.397, 150.644),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new
google.maps.Map(document.getElementById(“map”),
options);
// somewhere in your HTML templates
<div id=“map”></div>
•
–
– touchend
•
–
–
addListener()
google.maps.event.addListener(obj, eventname, callback)
•
–
•
–
–
•
addDOMListener(obj, eventname, callback)
addListener, obj
var map = new
google.maps.Map(document.getElementById(“map”),
opt);
google.maps.event.addListener(map, 'click',
function(event) {
var marker = new google.maps.Marker({
position: event.latLng,
map: map
});
map.setCenter(marker.getPosition());
}
);
•
•
•
•

•
–
–
•
–
–
•
–
–
•
–
–
–
•
–
–
•
–

marker = new google.maps.Marker({
// options
});
google.maps.event.addListener(marker, 'click',
callback);
google.maps.Marker
•
– LatLng
•
– Map
– setMap()
– setMap() null
•
– google.maps.Animation.DROP
– google.maps.Animation.BOUNCE
setAnimation()
•
–
•
–
–
–
Polyline LatLngs
Marker Polyline
•
– LatLng
•
–
•
–
•
–
•
–
var map; // the map object (initialization omitted here)
var coords = [
new google.maps.LatLng(37.772323, -122.214897),
new google.maps.LatLng(21.291982, -157.821856),
new google.maps.LatLng(-18.142599, 178.431),
new google.maps.LatLng(-27.46758, 153.027892)
];
var polyline = new google.maps.Polyline({
path: coords,
strokeColor: "#00FF00",
strokeOpacity: 1.0,
strokeWeight: 1
});
polyline.setMap(map);
•
•
•
google.maps.DirectionsService
DirectionsService
DirectionsRequest
DirectionsService.route()
manageRoute
var dirService = new google.maps.DirectionsService();
var request = {
origin: ”…”,
destination: “…”,
travelMode: google.maps.TravelMode.DRIVING
};
dirService.route(request, manageRoute);
Geolocation and Mapping in PhoneGap applications
– DirectionsRoute
–
Geolocation and Mapping in PhoneGap applications
• DirectionsLeg
•
• LatLngs
• LatLngBounds
•
•
• DirectionsStep
•
•
• LatLng
•
LatLng
•
•
•
•
•
• LatLng
•
LatLng
Geolocation and Mapping in PhoneGap applications

google.maps.DistanceMatrixService
.getDistanceMatrix(options, callback)
•
–
•
–
•
–
•
–
•
–
–
–
•
–
–
•
•
• DistanceMatrixResponse
• DistanceMatrixStatus
•
–
•
–
•
–
•
–
–
var origin = “L‟Aquila, Italy";
var destination = “London, England";
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix({
origins: [origin],
destinations: [destination],
travelMode: google.maps.TravelMode.DRIVING,
avoidHighways: false,
avoidTolls: false
}, callback);
function callback(response, status) {
if (status == google.maps.DistanceMatrixStatus.OK) {
var t = response.rows[0].elements[0].distance.text;
alert(t);
}
}
 42.362319,13.368514

var geocoder = google.maps.Geocoder();
geocoder.geocode(options, callback);
•
– 
– 
–
–
•
•
–
GeocoderResults
geocoder = new google.maps.Geocoder();
var address = “via Vetoio 1, L‟Aquila”;
geocoder.geocode( { 'address': address}, callback);
function callback(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
for(result in results) {
console.log(result.geometry.location);
}
} else {
console.log(status);
}
}
•
–
–
•
–
•
–
•
•
–
Geolocation and Mapping in PhoneGap applications
Geolocation and Mapping in PhoneGap applications

More Related Content

PDF
Geolocation and mapping using Google Maps services
PDF
[2015/2016] Geolocation and mapping
PDF
Geolocation and Mapping
PDF
Mobile geolocation and mapping
PPTX
Integration of Google-map in Rails Application
PDF
Geolocation on Rails
KEY
Introduction to Game Programming Tutorial
KEY
Intro to Game Programming
Geolocation and mapping using Google Maps services
[2015/2016] Geolocation and mapping
Geolocation and Mapping
Mobile geolocation and mapping
Integration of Google-map in Rails Application
Geolocation on Rails
Introduction to Game Programming Tutorial
Intro to Game Programming

What's hot (15)

PDF
Core Location and Map Kit: Bringing Your Own Maps [Voices That Matter: iPhone...
PDF
Geolocation Databases in Ruby on Rails
KEY
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
PPT
Askayworkshop
KEY
How Quick Can We Be? Data Visualization Techniques for Engineers.
PDF
Exploring Canvas
PDF
Getting Oriented with MapKit: Everything you need to get started with the new...
PDF
Th 0230 turbo_chargeyourui-howtomakeyourandroidu_ifastandefficient
PDF
How to build a html5 websites.v1
PPTX
Python en la Plataforma ArcGIS
PDF
Keeping Track of Moving Things: MapKit and CoreLocation in Depth
PPTX
Get mapping with leaflet js
KEY
Introduction to MapKit
PDF
Google Maps Api
PPTX
Developing Applications with Microsoft Virtual Earth
Core Location and Map Kit: Bringing Your Own Maps [Voices That Matter: iPhone...
Geolocation Databases in Ruby on Rails
Ioannis Doxaras on GIS and Gmaps at 1st GTUG meetup Greece
Askayworkshop
How Quick Can We Be? Data Visualization Techniques for Engineers.
Exploring Canvas
Getting Oriented with MapKit: Everything you need to get started with the new...
Th 0230 turbo_chargeyourui-howtomakeyourandroidu_ifastandefficient
How to build a html5 websites.v1
Python en la Plataforma ArcGIS
Keeping Track of Moving Things: MapKit and CoreLocation in Depth
Get mapping with leaflet js
Introduction to MapKit
Google Maps Api
Developing Applications with Microsoft Virtual Earth
Ad

Similar to Geolocation and Mapping in PhoneGap applications (6)

KEY
W3C Geolocation
PDF
PhoneGap: Accessing Device Capabilities
PPTX
Paperjs presentation
PPTX
Paperjs presentation
PDF
ECMAScript 6 major changes
PDF
HTML5勉強会#23_GeoHex
W3C Geolocation
PhoneGap: Accessing Device Capabilities
Paperjs presentation
Paperjs presentation
ECMAScript 6 major changes
HTML5勉強会#23_GeoHex
Ad

More from Ivano Malavolta (20)

PDF
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
PDF
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
PDF
The H2020 experience
PDF
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
PDF
Software sustainability and Green IT
PDF
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
PDF
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
PDF
Collaborative Model-Driven Software Engineering: a Classification Framework a...
PDF
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
PDF
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
PDF
Modeling behaviour via UML state machines [Software Design] [Computer Science...
PDF
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
PDF
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
PDF
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
PDF
Modeling and abstraction, software development process [Software Design] [Com...
PDF
[2017/2018] Agile development
PDF
Reconstructing microservice-based architectures
PDF
[2017/2018] AADL - Architecture Analysis and Design Language
PDF
[2017/2018] Architectural languages
PDF
[2017/2018] Introduction to Software Architecture
On-Device or Remote? On the Energy Efficiency of Fetching LLM-Generated Conte...
Conducting Experiments on the Software Architecture of Robotic Systems (QRARS...
The H2020 experience
The Green Lab - Research cocktail @Vrije Universiteit Amsterdam (October 2020)
Software sustainability and Green IT
Navigation-aware and Personalized Prefetching of Network Requests in Android ...
How Maintainability Issues of Android Apps Evolve [ICSME 2018]
Collaborative Model-Driven Software Engineering: a Classification Framework a...
Experimenting on Mobile Apps Quality - a tale about Energy, Performance, and ...
Modeling objects interaction via UML sequence diagrams [Software Design] [Com...
Modeling behaviour via UML state machines [Software Design] [Computer Science...
Object-oriented design patterns in UML [Software Design] [Computer Science] [...
Structure modeling with UML [Software Design] [Computer Science] [Vrije Unive...
Requirements engineering with UML [Software Design] [Computer Science] [Vrije...
Modeling and abstraction, software development process [Software Design] [Com...
[2017/2018] Agile development
Reconstructing microservice-based architectures
[2017/2018] AADL - Architecture Analysis and Design Language
[2017/2018] Architectural languages
[2017/2018] Introduction to Software Architecture

Recently uploaded (20)

PPT
Module 1.ppt Iot fundamentals and Architecture
PPTX
The various Industrial Revolutions .pptx
PDF
Hybrid model detection and classification of lung cancer
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
STKI Israel Market Study 2025 version august
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Enhancing emotion recognition model for a student engagement use case through...
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PPTX
observCloud-Native Containerability and monitoring.pptx
PPT
Geologic Time for studying geology for geologist
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
A review of recent deep learning applications in wood surface defect identifi...
PPT
What is a Computer? Input Devices /output devices
PDF
Getting Started with Data Integration: FME Form 101
PDF
sustainability-14-14877-v2.pddhzftheheeeee
DOCX
search engine optimization ppt fir known well about this
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Hindi spoken digit analysis for native and non-native speakers
Module 1.ppt Iot fundamentals and Architecture
The various Industrial Revolutions .pptx
Hybrid model detection and classification of lung cancer
Univ-Connecticut-ChatGPT-Presentaion.pdf
STKI Israel Market Study 2025 version august
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Enhancing emotion recognition model for a student engagement use case through...
Final SEM Unit 1 for mit wpu at pune .pptx
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
observCloud-Native Containerability and monitoring.pptx
Geologic Time for studying geology for geologist
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
A review of recent deep learning applications in wood surface defect identifi...
What is a Computer? Input Devices /output devices
Getting Started with Data Integration: FME Form 101
sustainability-14-14877-v2.pddhzftheheeeee
search engine optimization ppt fir known well about this
NewMind AI Weekly Chronicles – August ’25 Week III
Group 1 Presentation -Planning and Decision Making .pptx
Hindi spoken digit analysis for native and non-native speakers

Geolocation and Mapping in PhoneGap applications