Dec 20, 2015
Developing Mobile Solutions Developing Mobile Solutions with MapPoint Web Servicewith MapPoint Web ServiceRik TemminkRik Temmink
AgendaAgenda
MapPointMobileMapPointMobile demodemoMapPoint System overviewMapPoint System overviewBuilding mobile MapPoint applicationsBuilding mobile MapPoint applications
EfficientEfficient: caching and pre-fetching maps: caching and pre-fetching mapsFastFast: optimizing and avoiding web calls: optimizing and avoiding web callsEngagingEngaging: dynamic map Interaction: dynamic map Interaction
Best practicesBest practicesFuture developmentsFuture developments
Mapping at MicrosoftMapping at Microsoft
19951995
• MapPoint BU established
• First consumerproducts
20012001
• Introduced MapPoint Web Service
• Launched MSN M&D
19991999
• Vicinity acquisition• Launched ‘04 CD
titles
• Added business mapping
• Added mobile products
20032003
• Released GPS bundle• Introduced MapPoint
Location Server• Pocket Streets for
SmartPhone
20052005
Maps & Maps & DirectionsDirections
Streets & Trips AutoRoute
MapPoint CDs
Maps & Directions
Integration AdvantageIntegration Advantage
MapPoint Location Server
Pocket StreetsFor Pocket PC & Smartphone
MapPointWeb Service
MapPoint ScenariosMapPoint ScenariosConsumerConsumer BusinessBusiness
Store LocatorStore LocatorRetail business Retail business location finderlocation finder
Travel PortalTravel PortalMapping of POIs: Mapping of POIs: hotels, hotels, restaurants, restaurants, attractions, etc.attractions, etc.
Field Service Field Service ManagementManagement
Reschedule and Reschedule and reroute service reroute service
technicians to new technicians to new customerscustomers
Call CentreCall CentreQuickly route Quickly route customers to customers to the next storethe next store
Fleet / Asset TrackingFleet / Asset TrackingIntegration of real time Integration of real time tracking, routing and tracking, routing and mapping into fleet mapping into fleet managementmanagement
MobileMobileDevicesDevicesFind the nearest Find the nearest Starbucks, post Starbucks, post office, or even your office, or even your buddy!buddy!
Location by PhoneLocation by PhoneExperience via:Experience via:1-800-545-0118 1-800-545-0118
Yellow PagesYellow PagesExperience at: Experience at:
http://maps.msn.comhttp://maps.msn.com
MapPoint Web ServiceMapPoint Web Service
Data
ApplicationsDevices
MapPoint Location Server
MapPoint Location Server
MapPoint Web ServiceMapPoint Web Service
Microsoft Mobile apps
Store Locator
Construction
Cartographic
Points of Interest(Yellow Pages)
Real-Time Traffic
APIs
Extranet
Database• Config info• Account info• Customer POI• Custom icons
• Get maps• Find places/addrs• Driving directions• Proximity searches• Reverse geocoding• Batch geocoding• Address parsing• Address clean-up
• Manage billing info• View xaction reports• Change passwords• Upload POI/icons
HTTPSOAP
VoiceSMSWAP
SOAP/HTTPRequests
Maps, POI, Traffic, etc
Asset Mgt
Yellow Pages
.NET Framework Visual Studio .NETLinux*, Perl*, Java*
Mobile Operator Network Customer Network
MapPoint Location ServerMapPoint Location ServerMapPoint Location ServerMapPoint Location Server
Database
Features / APIs
MapPoint Location ServerMapPoint Location Server
Mobile Operator’sLocation Service
WLANProvider
OtherProvider
WWANProvider
Provider Manager
• User profile• Privacy • Config• Logging
• User profile mgt• Locate users• Privacy mgt• Web service proxy
Ad
min
UI
SOAP
HTTPS
MapP
oint W
eb Service
Microsoft Network
Securechannel
Mobile client apps
SOAPHTTPS
Client applications
AgendaAgenda
MapPointMobileMapPointMobile demodemoMapPoint System overviewMapPoint System overviewBuilding mobile MapPoint applicationsBuilding mobile MapPoint applications
EfficientEfficient: caching and pre-fetching maps: caching and pre-fetching mapsFastFast: optimizing and avoiding web calls: optimizing and avoiding web callsEngagingEngaging: dynamic map Interaction: dynamic map Interaction
Best practicesBest practices
Find ServiceFind Service
Find addresses and geographic Find addresses and geographic entitiesentitiesFind POI spatially or along routesFind POI spatially or along routesParse addressesParse addresses
FindAddressSpecification myFAS = new FindAddressSpecification();
myFAS.InputAddress = my Address objectmyFAS.DataSourceName = “MapPoint.NA”;FindResults results = FindService.FindAddress(myFAS);
FindAddressSpecification myFAS = new FindAddressSpecification();
myFAS.InputAddress = my Address objectmyFAS.DataSourceName = “MapPoint.NA”;FindResults results = FindService.FindAddress(myFAS);
Route ServiceRoute Service
Calculates routes and itineraryCalculates routes and itineraryShortest or quickest route optionsShortest or quickest route optionsUse CalculateSimpleRoute for Use CalculateSimpleRoute for LatLong point based routesLatLong point based routes
Route myRoute = RouteService.CalculateSimpleRoute(LatLong[], "MapPoint.NA",SegmentPreference.Quickest);
Segment tripSegment = myRoute.Itinerary.Segments[0];foreach (Direction step tripSegment.Directions)
Console.WriteLine(step.Instruction);
Route myRoute = RouteService.CalculateSimpleRoute(LatLong[], "MapPoint.NA",SegmentPreference.Quickest);
Segment tripSegment = myRoute.Itinerary.Segments[0];foreach (Direction step tripSegment.Directions)
Console.WriteLine(step.Instruction);
Render ServiceRender Service
Render maps to show icons, routesRender maps to show icons, routes30 map styles available30 map styles available
4 designed specifically for devices4 designed specifically for devices
MapSpecification mapSpec = new MapSpecification(); mapSpec.DataSourceName = “MapPoint.NA”;mapSpec.Options = desired size and stylemapSpec.Views = my MapViewRepresentation objectMapImage[ ] maps = RenderService.GetMap(mapSpec);Image mapImage =
new Bitmap(MemoryStream(maps[0].MimeData.Bits));
MapSpecification mapSpec = new MapSpecification(); mapSpec.DataSourceName = “MapPoint.NA”;mapSpec.Options = desired size and stylemapSpec.Views = my MapViewRepresentation objectMapImage[ ] maps = RenderService.GetMap(mapSpec);Image mapImage =
new Bitmap(MemoryStream(maps[0].MimeData.Bits));
MapPointMobile MapPointMobile DesignDesign
MapPointMobile.Common.dllMapPointMobile.Common.dllCustom UI control: MapZoomBarCustom UI control: MapZoomBarCustom UI control: MapControlCustom UI control: MapControlApplication stateApplication stateMap cacheMap cacheWeb Service wrapper classesWeb Service wrapper classesPersisted settingsPersisted settingsGeographic point conversionGeographic point conversion
PocketPC and Smartphone appsPocketPC and Smartphone apps
Common Classes: PushpinCommon Classes: Pushpin
public class Pushpin {
PushpinType Type; // POI, Address, Place, etc…string Name;LatLong Location;string IconName;Address PrimaryAddress;string PrimaryPhoneNumber;MapViewRepresentations BestMapView;…
}
public class Pushpin {
PushpinType Type; // POI, Address, Place, etc…string Name;LatLong Location;string IconName;Address PrimaryAddress;string PrimaryPhoneNumber;MapViewRepresentations BestMapView;…
}
Common Classes: MapStateCommon Classes: MapState
Wraps image and other data returned Wraps image and other data returned from RenderServicefrom RenderServiceUsed throughout the app, cached, Used throughout the app, cached, persisted, etc…persisted, etc…
public class MapState{
public Image MapImage;public HotArea[] HotAreas;public double ZoomLevel;public LatLong CenterPoint;…
}
public class MapState{
public Image MapImage;public HotArea[] HotAreas;public double ZoomLevel;public LatLong CenterPoint;…
}
Caching & Pre-Fetching MapsCaching & Pre-Fetching Maps
efficientefficient [ [i-físh-’nti-físh-’nt]]1.1. being effective without being effective without
wasting time or effort or wasting time or effort or expenseexpense
2.2. making smarter map making smarter map applications on Windows applications on Windows Mobile by reducing Mobile by reducing download timesdownload times
Caching MapsCaching Maps
Useful when users return frequently Useful when users return frequently to the same mapsto the same mapsIncreases application performanceIncreases application performanceReduces data bandwidth useReduces data bandwidth useMaintain cache order (e.g. MRU, FIFO)Maintain cache order (e.g. MRU, FIFO)Tip - use a Hashtable for map cache Tip - use a Hashtable for map cache
Key - generated from MapSpecificationKey - generated from MapSpecificationValue - save a “MapState” objectValue - save a “MapState” object
Cache Code SampleCache Code Sample
public MapState GetMap(MapSpecification mapSpec){
int key = mapSpec.GetHashCode();
if (mapCache.Contains(key)) {myMapState = cache.Items[key];
}else {
myMapState = RenderService.GetMap(mapSpec);cache.Add(key, myMapState);
}
return myMapState; }
public MapState GetMap(MapSpecification mapSpec){
int key = mapSpec.GetHashCode();
if (mapCache.Contains(key)) {myMapState = cache.Items[key];
}else {
myMapState = RenderService.GetMap(mapSpec);cache.Add(key, myMapState);
}
return myMapState; }
Pre-Fetching MapsPre-Fetching Maps
Useful when a user is stepping Useful when a user is stepping through driving directions or panning through driving directions or panning a mapa mapIncreases perceived performanceIncreases perceived performanceLeads to more cache hitsLeads to more cache hitsBut… application may download But… application may download more data than is necessarymore data than is necessary
Optimizing and ReducingOptimizing and ReducingWeb Service CallsWeb Service Calls
fast & flexiblefast & flexible [ [fast & fast & fléksəb’lfléksəb’l]]
1.1. acting or moving rapidly, acting or moving rapidly, able to bend without able to bend without breakingbreaking
2.2. able to handle complex able to handle complex geographic computations geographic computations on the deviceon the device
Local XY To LatLongLocal XY To LatLong
Determine the coordinate of a point Determine the coordinate of a point locallylocallyReduces calls to MapPoint WSReduces calls to MapPoint WSIncreases application performanceIncreases application performanceExamples…Examples…
Adding a pushpin to a point on the mapAdding a pushpin to a point on the mapHandling when points move off screenHandling when points move off screen
Local Pushpin RenderingLocal Pushpin Rendering
More flexibility with icons and More flexibility with icons and graphicsgraphicsIncreases application performanceIncreases application performanceReduces render calls to MapPointReduces render calls to MapPointMore cache hitsMore cache hitsNotes…Notes…
Pushpin icons can clobber labelsPushpin icons can clobber labelsImplement hit detect using hot areasImplement hit detect using hot areas
Optimizing Find Calls Optimizing Find Calls 1/31/3
Use ResultMask to filter unnecessary Use ResultMask to filter unnecessary returned informationreturned informationAvailable on Find, FindAddress and Available on Find, FindAddress and FindNearby callsFindNearby callsReturn or omit Address, Map View, Return or omit Address, Map View, LatLong location, entity IDLatLong location, entity ID
FindSpecification findSpec =new FindSpecification();
findSpec.Options.ResultMask = FindResultMask.AddressFlag;
FindService.Find(findSpec);
FindSpecification findSpec =new FindSpecification();
findSpec.Options.ResultMask = FindResultMask.AddressFlag;
FindService.Find(findSpec);
Optimizing Find Calls Optimizing Find Calls 2/32/3
Use FindRange to limit the number of Use FindRange to limit the number of entities returnedentities returnedAvailable on Find, FindAddress and Available on Find, FindAddress and FindNearby callsFindNearby callsSet starting index and number to Set starting index and number to returnreturn
FindSpecification findSpec =new FindSpecification();
findSpec.Options.FindRange = new FindRange();findSpec.Options.FindRange.StartIndex = 0;findSpec.Options.FindRange.Count = 10;FindService.Find(findSpec);
FindSpecification findSpec =new FindSpecification();
findSpec.Options.FindRange = new FindRange();findSpec.Options.FindRange.StartIndex = 0;findSpec.Options.FindRange.Count = 10;FindService.Find(findSpec);
Optimizing Find Calls Optimizing Find Calls 3/33/3
Specify EntityTypeName to narrow Specify EntityTypeName to narrow the scope of your searchthe scope of your searchAvailable on Find and FindNearby Available on Find and FindNearby onlyonlyExample…Example…
Find “Washington, USA” has 70+ resultsFind “Washington, USA” has 70+ resultsOnly 1 with filter = “AdminDivision1”Only 1 with filter = “AdminDivision1”
FindSpecification findSpec =new FindSpecification();
findSpec.InputPlace = “Washington, USA”;findSpec.Filter = new FindFilter();findSpec.Filter.EntityTypeName = “AdminDivision1“;FindService.Find(findSpec);
FindSpecification findSpec =new FindSpecification();
findSpec.InputPlace = “Washington, USA”;findSpec.Filter = new FindFilter();findSpec.Filter.EntityTypeName = “AdminDivision1“;FindService.Find(findSpec);
Dynamic Map InteractionDynamic Map Interaction
engagingengaging [ [en gáyjingen gáyjing]]1.1. charming or pleasing in a charming or pleasing in a
way that attracts and way that attracts and holds the attentionholds the attention
2.2. building the coolest building the coolest mapping applications on mapping applications on the coolest mobile the coolest mobile platformplatform
Drag PanningDrag Panning
Creates a more engaging experienceCreates a more engaging experienceReduces round trips to MapPointReduces round trips to MapPointUseful with stylus and d-padUseful with stylus and d-padDon’t forget…Don’t forget…
Labels may run off the sidesLabels may run off the sidesNot ideal for route overview maps Not ideal for route overview maps Maps will be 9x size of the map controlMaps will be 9x size of the map control
Static 240x240 map: 450 bytesStatic 240x240 map: 450 bytesDrag pan enabled: 4000 bytesDrag pan enabled: 4000 bytes
MapControl OverviewMapControl Overview
Custom control to handle map render Custom control to handle map render and user interactionand user interactionExposes 2 simple methods:Exposes 2 simple methods:
mapControl.RenderPin(pins, centerPin)mapControl.RenderPin(pins, centerPin)mapControl.RenderRoute(pins, route, mapControl.RenderRoute(pins, route, step)step)
4 modes: Pan, Zoom, Route, CrossHair4 modes: Pan, Zoom, Route, CrossHairFires events for location, mode and Fires events for location, mode and crosshair position changescrosshair position changesHandles relevant d-pad / stylus / key Handles relevant d-pad / stylus / key events, passes others to parent formevents, passes others to parent form
Handling a Large MapHandling a Large Map
Point: mapOffsetPoint: mapOffset
In OnMouseDown event override:mousePt = new Point(
mapOffset.X + e.X, mapOffset.Y + e.Y);foreach (HotArea target in mapState.HotAreas) {
if (target.Area.Contains(mousePt.X, mousePt.Y))SelectedPushpinChanged(this, args);
}
In OnMouseDown event override:mousePt = new Point(
mapOffset.X + e.X, mapOffset.Y + e.Y);foreach (HotArea target in mapState.HotAreas) {
if (target.Area.Contains(mousePt.X, mousePt.Y))SelectedPushpinChanged(this, args);
}
Zoom ControlZoom Control
Custom ZoomBar controlCustom ZoomBar controlUse discreet steps to promote cache Use discreet steps to promote cache hitshitsSnap “BestMapView” to nearest stepSnap “BestMapView” to nearest stepUse a timer to allow multiple level Use a timer to allow multiple level changes with one render callchanges with one render call
Zooming in MWSZooming in MWS
Use web service’s ViewByScale viewUse web service’s ViewByScale viewScale is the denominator of the ratio:Scale is the denominator of the ratio:
screen unit screen unit earth unitearth unit
Example: Scale = 502,000,000 earth Example: Scale = 502,000,000 earth rendered as 1 inch (at 96dpi)rendered as 1 inch (at 96dpi)
Zooming: Zoom RangeZooming: Zoom Range
Avoid a linear zoom levels to create Avoid a linear zoom levels to create more useful rangemore useful range
1 2 3 4 5 6 7 8 9 10
mwsScale = 10 * (zoomLevel mwsScale = 10 * (zoomLevel 4.34.3) + ) + 10001000
250ft250ft
1,000mi1,000mi
Tips and Tricks SummaryTips and Tricks Summary
Use cancellable asynchronous web Use cancellable asynchronous web methodsmethodsFind calls may return multiple resultsFind calls may return multiple resultsCache and pre-fetch mapsCache and pre-fetch mapsStore cache as a HashtableStore cache as a HashtableUse local calculations when possible Use local calculations when possible and appropriateand appropriateAvoid a linear zoom rangeAvoid a linear zoom range
MapPoint TodayMapPoint Today
MSN Maps & Directions has 6 million UU and growing
Streets & Trips #1 in desktop consumer mapping
MapPoint Location Server enables real-time location
Windows Mobile navigation and mapping
Location technology provider to other groups
User Experiences:
Mapping Platform:
MapPoint Web Service does 25 million transactions a day
Virtual EarthVirtual Earth
Virtual Earth will revolutionize online mapping experiences with Virtual Earth will revolutionize online mapping experiences with rich navigation tools, aerial and satellite images, perspective land rich navigation tools, aerial and satellite images, perspective land
views, real-time user location, traffic conditions, speech views, real-time user location, traffic conditions, speech interfaces, new and unique map styles, synchronization and interfaces, new and unique map styles, synchronization and
much more. much more.
Virtual Earth is a platform, experiences Virtual Earth is a platform, experiences and a community for capturing, and a community for capturing,
connecting, sharing and visualizing of connecting, sharing and visualizing of information based of location.information based of location.
Virtual EarthA place where everything about the real world is available in an online Virtual World
AutolocateAutolocate
It allows these applications to get information about It allows these applications to get information about the user’s location through visible WiFi access the user’s location through visible WiFi access points and a database of these access points’ points and a database of these access points’
location. location.
A software component that enables A software component that enables location awareness for Microsoft location awareness for Microsoft
applications. applications.
AutolocateA new component in the value proposition for wireless computing
Next StepsNext Steps
Sign-up for a Developer AccountSign-up for a Developer Accounthttp://www.microsoft.com/mappointhttp://www.microsoft.com/mappoint
Download Sample CodeDownload Sample Codehttp://msdn.microsoft.com/mappointhttp://msdn.microsoft.com/mappoint
Do cool things Do cool things
ResourcesResources
MapPoint SDK & TrainingMapPoint SDK & Traininghttp://msdn.microsoft.com/mappointhttp://msdn.microsoft.com/mappoint
Sample ApplicationsSample Applicationshttp://demo.mappoint.nethttp://demo.mappoint.net
NewsgroupsNewsgroupsmicrosoft.public.mappoint.webservicemicrosoft.public.mappoint.webservice
.NET Compact Framework.NET Compact Frameworkhttp://msdn.microsoft.comhttp://msdn.microsoft.com//smartclient/understanding/netcfsmartclient/understanding/netcf
Stephen Turner’s BlogStephen Turner’s Bloghttp://blogs.msdn.com/digilocityhttp://blogs.msdn.com/digilocity