Skip to content
Advertisement

Tag: node.js

How can I get city name from a latitude and longitude point?

Is there a way to get a city name from a latitude and longitude point using the google maps api for javascript? If so could I please see an example? Answer This is called Reverse Geocoding Documentation from Google: http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding. Sample Call to Google’s geocode Web Service: http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true&key=YOUR_KEY

Difference between console.log and sys.puts in node.js?

In node.js you can use console.log or sys.puts to print out to the screen. What is the preferred method and what is the difference between these? Answer sys.puts simply prints the given string in the logs. But if you want to print a more complex object (Array, JSON, JSObject) you have to use console.log because you want to “look inside”

How to append to a file in Node?

I am trying to append a string to a log file. However writeFile will erase the content each time before writing the string. Any idea how to do this the easy way? Answer For occasional appends, you can use appendFile, which creates a new file handle each time it’s called: Asynchronously: Synchronously: But if you append repeatedly to the same

How can I share code between Node.js and the browser?

I am creating a small application with a JavaScript client (run in the browser) and a Node.js server, communicating using WebSocket. I would like to share code between the client and the server. I have only just started with Node.js and my knowledge of modern JavaScript is a little rusty, to say the least. So I am still getting my

Advertisement