Resolve and code addresses using geocoding

文章推薦指數: 80 %
投票人數:10人

Documentation for HERE's HERE Maps API for Javascript. ... The HERE Geocoding and Search API unlocks the search and geocoding capabilities of HERE services ... DeveloperHEREMapsAPIforJavaScriptGuideAPIReferenceReleaseNotesExamplesResolveandcodeaddressesusinggeocoding·MapsAPIforJavaScriptVisitwww.here.comIntroductionGetstarted-HEREplatformGetstarted-HEREdeveloperportalBrowsersupportModulesAPIVersionsMigrationtotheMapsAPIforJavaScript3.1ConceptsMaptypesVectormaptypesStructureoverviewDefaultstylesCustomstylesFiltersSourcesGeopoliticalviewsRastermaptypesMapeventsMapobjectsMarkerobjectsOverlaysGeoshapesTutorialsGetstartedwithJapandataBundleHEREMapsAPIforJavaScriptModifyyourmapusingmapcontrolsandUIResolveandcodeaddressesusinggeocodingCalculateroutesRetrieveanddisplaytrafficdataClustermapdatasetsShowFleetTelematicsAdvancedDataSetslayeronthemapShowFleetTelematicsCustomLocationslayeronthemapCreatecontentusingKMLsupportDisplayaDataHubspaceonthemapIntegrateIndoorMapsWorkingwithReactWorkingwithAngularWorkingwithTypeScriptSettingdomainnameandservicepathBestpracticesResolveandcodeaddressesusinggeocodingResolveandcodeaddressesusinggeocodingResolvingaddressestogeocoordinatesandviceversaarecommonrequirementsforlocation-basedapplications.TheHEREGeocodingandSearchAPIunlocksthesearchandgeocodingcapabilitiesofHEREservicestoprovidedeveloperswithunmatchedflexibilitytocreatedifferentiatinglocation-enabledapplications.Italsosupportsareversegeocoding(obtainingastreetaddressthatcorrespondstoasetofgeo-coordinates)aswellaslandmarkgeocoding(findingairportsorlandmarksclassifiedasnationallyimportant).AllthesefeaturescanbeaccessedthroughtheMapAPI'sservicemodule(mapsjs-service.js)foreasyintegrationintoamapapplication.DisplayinggeocodingresultsonamapThefollowingexampleshowshowtogeocodetheaddress200SMathildaAve,Sunnyvale,CAandplaceamarkeratthereturnedlocationonthemap.Thecodesubmitsageocodingrequest,providingcallbackfunctionstohandletheresults.TherequestusesanobjectliteralwithmembersmatchingtheparameternamessupportedbytheHEREHEREGeocodingandSearchAPI.ThecontentsofspecifiedobjectliteralareconvertedbytheMapsAPItoURLparameters.TheparameterobjectcanincludeanyparametersrecognizedbytheHEREGeocodingandSearchAPI.Therequestisprocessedasynchronously,whichiswhythecallbacksareneeded.Thecallbackfunctioninvokedonsuccessplacesthemarkeronthemap,whiletheerrorcallbacksimplydisplaysanalert.//Instantiateamapandplatformobject: varplatform=newH.service.Platform({ 'apikey':'{YOUR_API_KEY}' }); //Getaninstanceofthegeocodingservice: varservice=platform.getSearchService(); //Callthegeocodemethodwiththegeocodingparameters, //thecallbackandanerrorcallbackfunction(calledifa //communicationerroroccurs): service.geocode({ q:'200SMathildaAve,Sunnyvale,CA' },(result)=>{ //Addamarkerforeachlocationfound result.items.forEach((item)=>{ map.addObject(newH.map.Marker(item.position)); }); },alert); Asuccessfulgeocodingrequestallowsthecodetodisplayamarkerforeachlocationfoundasshownintheimagebelow:Figure1.Themapafterretrievingthegeo-coordinatesfortheaddressReversegeocodingmaplocationsThefollowingexampleshowshowtoretrievetheaddressofthespecifiedpositioninBerlin,Germany(52.5309°N13.3847°E).Theresultisdisplayedonthemapwithaninfobubblemarkingthelocationoftheretrievedaddress.//Instantiateamapandplatformobject: varplatform=newH.service.Platform({ 'apikey':'{YOUR_API_KEY}' }); //Getaninstanceofthesearchservice: varservice=platform.getSearchService(); //Callthereversegeocodemethodwiththegeocodingparameters, //thecallbackandanerrorcallbackfunction(calledifa //communicationerroroccurs): service.reverseGeocode({ at:'52.5309,13.3847,150' },(result)=>{ result.items.forEach((item)=>{ //Assumption:uiisinstantiated //CreateanInfoBubbleatthereturnedlocationwith //theaddressasitscontents: ui.addBubble(newH.ui.InfoBubble(item.position,{ content:item.address.label })); }); },alert); Figure2.ThemapshowingtheretrievedaddressofalocationAutosuggestTheautosuggestendpointimprovesuser'ssearchexperiencebyallowingsubmittaloffree-form,incompleteandmisspelledaddressesorplacenamestotheendpoint.ThefollowingexampleshowshowtosearchforChicagoO'HareInternationalAirport(ORD).//Instantiateamapandplatformobject: varplatform=newH.service.Platform({ 'apikey':'{YOUR_API_KEY}' }); //Getaninstanceofthesearchservice: varservice=platform.getSearchService(); //Callthe"autosuggest"methodwiththesearchparameters, //thecallbackandanerrorcallbackfunction(calledifa //communicationerroroccurs): service.autosuggest({ //Searchquery q:'ChicagoORD', //Centerofthesearchcontext at:'38.71014896078624,-98.60787954719035' },(result)=>{ let{position,title}=result.items[0]; //Assumption:uiisinstantiated //CreateanInfoBubbleatthereturnedlocation ui.addBubble(newH.ui.InfoBubble(position,{ content:title })); },alert); Whentherequestissuccessful,thecallbackfunctiondisplaysaninfobubbleonthemap:Figure3.Themapafterretrievinglandmarkinformationresultsmatching""Noresultsmatching""



請為這篇文章評分?