﻿
var map;
var cgm;
var resultsLayer;
//var mbounds;
//var photosLayer;
//var servicePath = "";

$(document).ready(function() {
	//mapInit();
	//$(":checkbox:not(.layer-group)").click(layerClick);
});

function mapInit() {
	if ($("#map_canvas").length > 0) {
		map = new GMap2($("#map_canvas").get(0));
		map.setCenter(new GLatLng(33.823215, -116.512114), 11);

		//var mapTypePos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10, 10));
		//var mapControlPos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10, 50));

		//map.addControl(new GLargeMapControl(), mapControlPos);
		//map.addControl(new GMapTypeControl(), mapTypePos);
		//map.addControl(new GScaleControl());

		map.enableContinuousZoom();
		map.enableScrollWheelZoom();

		cgm = new CRGGoogleMap(map, { maxInitZoom: 12, minClusterSize: 0 });
		//cgm.onLayersLoadStart = function() { $("#loading").show(); };
		//cgm.onLayersLoadComplete = function() { $("#loading").hide(); };
		//cgm.onZoomEnd = function(o, n) { setupLayers(); };
		cgm.initialize();

		if (typeof (FeaturedEntries) != "undefined") {
			ml = new MapLayer("Featured", "/WebServices/MapService.svc/GetOverlayByEntryId", { 'entryIds': FeaturedEntries }, { visible: true, center: false, filterMb: false, cluster: false, clusterGridSize: 0 });
			ml.MarkerOptions = { icon: createicon('/images/map/marker_greenstar.png') };
			ml.onClick = function() { };
			ml.onMarkerMouseOver = featuredMarkerHover; //function() { alert('hover'); };
			cgm.addLayer(ml);
		}

		var geoEntryIds = "";
		resultsLayer = new MapLayer("Results", "/WebServices/MapService.svc/GetOverlayByEntryId", { 'entryIds': geoEntryIds }, { visible: true, center: false, filterMb: false, autoLabel: true, cluster: false, clusterGridSize: 0 });
		resultsLayer.MarkerOptions = { icon: createicon('/images/map/marker_orangeblank.png'), labelOffset: new GSize(8, -25) };
		resultsLayer.onClick = function() { };
		resultsLayer.onMarkerMouseOver = markerHover;
		cgm.addLayer(resultsLayer);
	}
}
