Wednesday, October 14, 2009

Google Static Map

A new component in JSOS - proxy for Google Static Map. The Google Static Maps API lets you embed a Google Maps image on your webpage without requiring JavaScript or any dynamic page loading. Bit it requires a key (free registration on Google). And this API key is connected with some domain. So if you are distributing your map it could be a problem – map will be actually requested from some other domain. This proxy lets you always perform request from your domain (domain associated with key):

Just describe servlet and mapping:

<servlet>
  <servlet-name>StaticMap</servlet-name>
  <servlet-class>com.jsos.staticmap.StaticMapProxyServlet</servlet-class>
</servlet>

<servlet-mapping>
  <servlet-name>staticMap</servlet-name>
  <url-pattern>/servlet/staticmap</url-pattern>
</servlet-mapping>


and now you can request static map by this way:

http://your_host/servlet/staticmap?key=your_key&maptype = mobile&markers = 40.8403347,-82.2393255 &size=240x320&zoom=16


P.S. original component used for this custom proxy is generic HTTP proxy.

No comments: