Loading ...

Embedding Google Maps in an Acumatica ASPX Page

Integrating Google Maps into an Acumatica ASPX page offers users the ability to leverage the Google Maps JavaScript API for dynamic and interactive map features. This article explores a straightforward approach to embedding Google Maps within your Acumatica customization.

Setting Up Google Maps Integration

To embed Google Maps in an ASPX page in Acumatica, follow these steps:

Step 1: Include Google Maps JavaScript API

The first step is to load the Google Maps API into your page using a PXLiteral control. This control allows you to insert raw HTML or JavaScript into the page. Ensure you have a valid API key from Google to replace the demo key used below.

<px:PXLiteral Enabled="True" runat="server" ID="s1"

    Text="&lt;script async defer src='https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY'>&lt;/script>" />

Step 2: Initialize the Map with JavaScript

Add another PXLiteral to define the JavaScript required to initialize and display the map.

Step 3: Create a Placeholder for the Map

Use another PXLiteral to define the div element where the map will render.

<px:PXLiteral Enabled="True" runat="server" ID="s3"

    Text="&lt;div id='map' style='height: 400px; width: 600px;'></div>" />

Step 4: Testing and Debugging

●      API Key: Replace YOUR_API_KEY with your valid Google Maps API key.

●      Customization Editor: Add these literals in the Acumatica Customization Project Editor.

●      Script Handling: Avoid single-line comments in your JavaScript, as PXLiteral compiles the script into a single line, potentially breaking the code.

Additional Considerations

Embedding Static Maps

For simpler use cases, you can embed a static Google Map using an iframe within a PXLabel control.

<px:PXLabel ID="GoogleMap" runat="server"

    Text="&lt;iframe src='https://www.google.com/maps/embed?...' style='width:600px;height:400px;'>&lt;/iframe>" />

Backend Limitations

While Google Maps API does not impose a strict limit on data points, transferring a large number of points from the Acumatica backend to the JavaScript frontend could introduce performance bottlenecks. Optimize data transfer by batching records or simplifying dataset sizes.

Key Takeaways

●      Use PXLiteral to embed and run JavaScript or HTML within an Acumatica ASPX page.

●      Ensure valid API keys are used to avoid connectivity issues.

●      For extensive datasets, consider performance implications and optimize backend-to-frontend data flows.

By integrating Google Maps, you can enhance your Acumatica application's interactivity and provide users with dynamic location-based functionality.