Anyone have any insight on how I would include an ...
# suitescript
e
Anyone have any insight on how I would include an external library (google maps in this case) in a map/reduce script?
j
For server scripts, it depends a lot on the shape and features of the external library. You cannot include anything unless it exports its members as AMD or UMD (i.e. uses the
define
pattern or has some type of detection to use the
define
pattern). Additionally any library that you import on the server cannot have any browser or node js dependencies. Generally as a rule of thumb if it has any runtime dependencies at all (i.e. isn't "pure" javascript), it probably won't work on the server. E.g. since the only way to make http requests on netsuite server is with the
N/http
modules, the google maps library had better not need to request any data 🙂
e
I was thinking I could use a custom module and just see what happens. Can the define portion call a URL? This looks like it can, but I am not sure I can do this in NS. (https://stackoverflow.com/questions/14755644/initializing-google-maps-as-an-amd-module)
I'm only looking to see if a marker is in a region, the geocoding is already done
j
🤷 I'd be pretty surprised if it worked on the netsuite server, so definitely share if you get it running. I'm not familiar with the google maps api, but maybe they have a REST endpoint that you can call to