Anonymous user  |  Log in  |  Create Account

Minimize Code

The Google Maps control for ASP.NET is very powerful, as it is not only an ASP.NET to Javascript parser, but brings us some extra features, unavailable in the Google Maps API.

However, sometimes it's not necessary to use the whole tool, so we can set some options to minimize the code footprint and size.

If our only objective is to show maps with GPolygons or GMarkers, and we don't want the user to be able to interact with the map, we may use Static Maps, which returns a simple non-interactive image.

The Static Map, however, is not enough many times, so there are some other options we can apply to the map to minimize the code:

  • enablePostBackPersistence: if the page containing the map is not going to do any PostBack, it is recommended to disable this option (by default is enabled).
  • enableGetGMapElementById: in case we are not using the getGMapElementById option, it is recommended disable it (by default is enabled).
  • enableStore: in case we are not using Store you shouldn't enable it (by default is disabled).
  • enableServerEvents: it only has to be enabled when you are using server events (by default is disabled).
Code.aspx
<cc1:GMap ID="GMap1" runat="server" />
Code.aspx.cs
GMap1.enablePostBackPersistence = false;
GMap1.enableGetGMapElementById = false;
GMap1.enableStore = false;
GMap1.enableServerEvents = false;
Powered by Subgurim.NET