/*
 * Copyright (c) 2009 Ewert Technologies
 *
 * All rights, including copyrights and patent rights are reserved.
 * This software is the confidential and proprietary information of Ewert
 * Technologies ("Confidential Information"). No copies of any portion are to
 * be made by whatever means without the express written permission of
 * Ewert Technologies.
 *
 * File Information:
 * $$HeadURL: svn://EWE04/web/projects/ewert_technologies/trunk/assets/js/coordinateConverter.js $$
 * $$Revision: 248 $$
 * $$Date: 2009-12-06 19:57:57 -0800 (Sun, 06 Dec 2009) $$
 * $$Author: vewert $$
 */

/*
 * Does the initial load of the google map.
 */
function initialize(latitude, longitude) {
  var latlng = new google.maps.LatLng(latitude, longitude);
  var title = latitude + ", " + longitude;
  var myOptions = {
      zoom: 4,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
  var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}

/*
 * Updates the map with parameter passed in the by the applet.
 * Called from within the applet.
 */
function updateMap(latitude, longitude, text) {
  var alertText = latitude + ", " + longitude + "\n" + text;
  var latlng = new google.maps.LatLng(latitude, longitude);
  var title = latitude + ", " + longitude;
  var myOptions = {
      zoom: 8,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
  var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

  var contentString = text;

  var infoWindow = new google.maps.InfoWindow({
    content: contentString
  });

  var arrowShadowImg = '../assets/img/arrow_shadow.png';
  var markerShadow = new google.maps.Marker({
    position: latlng, 
    map: map, 
    icon: arrowShadowImg
  });

  var arrowImg = '../assets/img/arrow.png';        
  var marker = new google.maps.Marker({
    position: latlng, 
    map: map, 
    title: title,
    icon: arrowImg
  });        

  infoWindow.open(map, marker);

  google.maps.event.addListener(marker, 'click', function() {
    infoWindow.open(map,marker);
  });
}