SoFunction
Updated on 2025-03-10

Google Map API update implements user-defined annotation coordinates


if(typeof GoogleMap === 'undefined'){
var GoogleMap = {};
}
(function(){
if (!("fgmap")) {
return false;
}
else {
// Is it possible to create Google Maps controls
var isCompatible = new GBrowserIsCompatible();
if (isCompatible) {
var mapContainer = ("fgmap");
// Create Google MAP map instance
var map = new GMap2(mapContainer);
// The default scale level of the map
var perviewLevel = 14;
// Large map zoom level control
var largeMapControl = new GLargeMapControl();
// Map thumbnail control
var overviewMapControl = new GOverviewMapControl();
// Scale control
var scaleControl = new GScaleControl();
// Map type selection control
var mapTypeControl = new GMapTypeControl();
// Address-coordinate converter
var geocoder = new GClientGeocoder();
// Last query address
var lastAddress = '';
// Last query coordinates
var lastPoint = null;
// The last created markup control
var lastMarker = null;
// The last coordinate point of the user tag
var cusLastPoint = null;

= [];

// Create a map
= function(lat, lng){
var point = new GLatLng(lat, lng);
(G_PHYSICAL_MAP);
(point, perviewLevel);

();
();
();

(largeMapControl)
(overviewMapControl);
(mapTypeControl);
(scaleControl);
};

// Create tags
= function(latlng, markerOptions){
var marker = markerOptions ? new GMarker(latlng, markerOptions) : new GMarker(latlng);
lastMarker = marker;
return marker;
};

// Custom tag options
/* =========================================================================================================================================================================================
Parameter description:
Constant: The default icon used by the G_DEFAULT_ICON tag.
image String icon foreground image URL.
shadow String icon shadow image URL.
iconSize GSize pixel size of the foreground image of the GSize icon.
shadowSize GSize The pixel size of the shadow image.
iconAnchor GPoint The anchor point of this icon on the map is relative to the pixel coordinates in the upper left corner of the icon image.
infoWindowAnchor GPoint Information window The anchor point on this icon is relative to the pixel coordinates in the upper left corner of the icon image.
printImage String The URL of the foreground icon image used to print the map. Its size must be the same as the size of the main icon image provided by image.
mozPrintImage String The URL of the foreground icon image used to print the map with Firefox/Mozilla. Its size must be the same as the size of the main icon image provided by image.
printShadow String The URL of the shadow image used to print the map. Since most browsers cannot print PNG images, the image format should be GIF.
transparent String The URL of the transparent foreground icon image used when capturing a click event in Internet Explorer. This image should be a main icon image in 24-bit PNG format with 1% opacity, but with the same size and shape as the main icon.
imageMap Array of Number represents an array of integers for the x/y coordinates of the image map, which specifies the clickable part of the icon image in the browser (not Internet Explorer).
maxHeight Integer Specifies the distance (in pixels) that is visually vertically "rise" when dragging the mark. (Since 2.79)
dragCrossImage String Specifies the URL of the cross image when dragging the icon. (Since 2.79)
dragCrossSize GSize Specifies the pixel size of the cross image when dragging the icon. (Since 2.79)
dragCrossAnchor GPoint Specifies the pixel coordinate offset of the cross image when dragging the icon (relative to iconAnchor). (Since 2.79)
========================================================================================================================================================================================= */
= function(IconOptions){
var myIcon = new GIcon(G_DEFAULT_ICON), i;
for (i in IconOptions) {
switch (i) {
case 'iconSize':
case 'shadowSize':
case 'dragCrossSize':
myIcon[i] = new GSize(IconOptions[i][0], IconOptions[i][1]);
break;
case 'iconAnchor':
case 'infoWindowAnchor':
case 'infoShadowAnchor':
case 'dragCrossAnchor':
= new GPoint(IconOptions[i][0], IconOptions[i][1]);
break;
default:
myIcon[i] = IconOptions[i];
break;
}

}
return myIcon;
};

// User-defined labels
= function(){
var marker = null;
var markPoint = cusLastPoint ? new GLatLng(cusLastPoint[0],cusLastPoint[1]) : new GLatLng(lastPoint[0],lastPoint[1]);
var markOptions = {
icon: ({
image: '/effects/img/'
}),
draggable: true
};

marker = (markPoint, markOptions);
(marker, "dragstart", function(){
();
});
(marker, "dragend", function(){
var custPoint = ();
var markTip = '<div class="fgmap_markerMsg" >';
markTip += '<h4>User Map Annotation</h4>';
markTip += '<div ><p>Current latitude and longitude: (' + () + ',' + () + ')<br />';
markTip += 'Does the new location be set to the default location of this merchant? </p>';
markTip += '<div class="MDB" style="text-align:center;"><button ';
(markTip);
});
(marker);
};

// Save user-defined coordinates
= function(){
var savedPoint = ();
var lat = (), lng = ();
var markTip = ('cusMarkTip');
= '<h4>Uploading the coordinate information you saved...</h4>';
if (timer) {
clearTimeout(timer);
}
var timer = setTimeout(function(){
();
var marker = (savedPoint);
if () {
(marker, "click", function(){
var msg = '<span class="fgmap_markerMsg">', j;
msg += '<h4>' + [1][0] + '</h4>';
for (var j = 1; j < [1].length; j++) {
msg += [1][j] + "<br />";
}
msg += "</span>";
(savedPoint, msg);
});
}
(marker);
(savedPoint);
cusLastPoint = [lat,lng];
}, 2000);
};

// Cancel the user-defined coordinate operation
= function(){
(lastMarker);
();
};

// Obtain coordinates through the address
= function(response){
var place = [0];
var point = new GLatLng([1], [0]);
return [[1], [0], point, place];
};

// Mark coordinates and corresponding instructions
= function(lat, lng){
var marker = null;
var point = new GLatLng(lat, lng);
(lat, lng);

marker = (point);
if () {
(marker, "click", function(){
var msg = '<span class="fgmap_markerMsg">', j;
msg += '<h4>' + [1][0] + '</h4>';
for (var j = 1; j < [1].length; j++) {
msg += [1][j] + "<br />";
}
msg += "</span>";
(point, msg);
});
}
(marker);
};

// Add query address to map
= function(response){
();
if (!response || != 200) {
alert("Sorry, we cannot resolve the latitude and longitude coordinates of the address!");
}
else {
var marker = null, point = (response);
var address = point[3].address, lat = point[0], lng = point[1];
= ( !== '' && (lastAddress === [0])) ? : [address, [point[3].address, ('Longitude: ' + point[1]), ('Latitude: ' + point[0])]];
(lat, lng);
lastPoint = [lat,lng];
}
};

// Add query coordinates to the map
= function(cPoint){
();
var marker = null, lat = cPoint[0], lng = cPoint[1];
(lat, lng);
lastPoint = [lat,lng];
};

// Show Marker on the map via address/coordinates
= function(cPoint){
if (typeof cPoint === 'string') {
(cPoint, );
lastAddress = cPoint;
}
else{
(cPoint);
}
};

(window, 'unload', GUnload);
}
else {
alert("Sorry, your browser does not support creating maps!");
}
}
})();