plot_google_map开源项目

我要开发同款
匿名用户2021年11月23日
44阅读
所属分类、应用工具、科研计算工具
授权协议BSD-2-Clause License

作品详情

plot_google_mapMATLABfunctionforplottingaGooglemaponthebackgroundofafigure

plot_google_map.musestheGoogleMapsAPItoplotamapinthebackgroundofthecurrentfigure.ItassumesthecoordinatesofthecurrentfigureareintheWGS84datum,andusesaconversioncodetoconvertandprojecttheimagefromthecoordinatesystemusedbyGoogleintoWGS84coordinates.Thezoomlevelofthemapisautomaticallydeterminedtocovertheentireareaofthefigure.Additionally,ithastheoptiontoauto-refreshthemapuponzoominginthefigure,revealingmoredetailsasonezoomsin.

Thefollowingcodeproducesthescreenshot:

plot_google_map('apiKey','<Your_API_Key>')%Youonlyneedtorunthisonce,whichwillstoretheAPIkeyinamatfileforallfutureusageslat=[48.870851.518841.926040.431252.52337.982];lon=[2.4131-0.130012.4951-3.678813.41523.715];plot(lon,lat,'.r','MarkerSize',20)plot_google_mapPrerequisites

DuetochangestotheGoogleMapsbillingmodel,younowmustsetyourownGoogleMapsAPIkeyandenablebillingforyourproject(seeinstructionshere).You'regettinganautomaticcreditof200$/month,whichwillbeenoughfor100,000staticmapscallswithoutactuallybeingbilled-moredetailshere.

Notethatthisdoesposesomechallengesifyouwanttodeployyourcode,asyourAPIkeywillneedtobedeployedwiththecode/asamatfileandhencemaybeexposedtousers.

KnownIssuesSavingthemapwithanimage/matrixoverlaydrawnontopofit(especiallyasemi-transparentone)cansometimescauseunexpectedresults(mapnotshowingetc.).Ifyou'reencounteringsuchproblems,it'srecommendedtousetheexport_figsubmission:https://www.mathworks.com/matlabcentral/fileexchange/23629-exportfigThecombinationthatseemstoworkbest:set(gcf,'renderer','zbuffer')export_fig('out.jpg')
声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论