Needs advice
on
JavaScriptJavaScriptNode.jsNode.js
and
PHPPHP

I want to make a delivery logistics web app for a small business that will run on our local server that uses Google Maps API and I’m wondering what would be the best language for that.

READ LESS
2 upvotes·16.1K views
Replies (1)
CTO at Cloudonix LTD.·
Recommends
on
PHP

It is mostly dependent on what you feel comfortable working with (or, if you are unfamiliar with either - whether you will better connect with either one, which is not easy to predict).

I personally prefer PHP as the language is more complete and has more robust runtimes platforms. Node.js can be problematic and the NPM.js ecosystem is much more problematic than even PHP's. That being said, each have their strengths and weaknesses and one of Node.js strongest appeal is that you can use more modern languages that build on top of Javascript - such as TypeScript and still use all the existing Javascript APIs.

Now regarding the Google Maps API - Google offers a Javascript API but not a PHP API, so please note that. Its important to understand what you are getting here - the Google Maps Javascript library is meant for frontend development - i.e. to run in the browser. You didn't explain what you expect to use the Google Maps API for, but if its for displaying a map on the website and letting users click that and interact with the map, then you'd need to use the Google Maps Javascript API, but it doesn't require any specific server implementation - even if you use the server Google API SDK with Node.js, it will still look and behave differently than the frontend API, because they are meant to do different things.

If you want to use the Google Maps API on the server - for example to updates places or get routing directions, you'd need to look at the Google API HTTP examples (here's the one for routing: https://developers.google.com/maps/documentation/directions/get-directions#maps_http_directions_toronto_montreal-txt ) and figure out how to use these in your server. The Google documentation has samples for Javascript but not for PHP, but the official Google PHP client library has documentation that explains how to use these examples with the PHP library: https://github.com/googleapis/google-api-php-client#making-http-requests-directly .

READ MORE
6 upvotes·2 comments·640 views
pharangerr
pharangerr
·
February 7th 2022 at 7:00PM

Thanks for the in depth answer. I plan on using the Google Maps API for estimating delivery times for scheduling in the system. I’m assuming that since this is my plan, Node.js is probably the way to go.

·
Reply
Oded Arbel
Oded Arbel
·
February 8th 2022 at 4:43PM

So that sounds like a backend API access, where you'd probably want the Directions and possibly Distance Matrix APIs. Note that for that you don't need to use an SDK and Google docs does not show how to use one - instead you are expected to use the HTTP client for your framework (the Google docs, such as that I linked in my recommendation, show how to use Axios for Javascript, instead of the Node.JS built-in one - for good reasons). If you aren't tied down to Node.js (for example, by overwhelming amount of experience with the platform) then I do recommend looking at other options (not just PHP) as there are many good frameworks available for other languages - for example, I use Eclipse Vert.x (https://vertx.io/) and I find it very easy to work with and very performant.

That being said, similar to the official Google PHP API library I linked, the official Google Github account at https://github.com/googleapis offers libraries for most popular languages so its probably worth taking a look, regardless of which server framework you decide to use.

·
Reply
Avatar of pharangerr