July 2010
M T W T F S S
« Jun    
 1234
567891011
12131415161718
19202122232425
262728293031  

Solve using multiple iFrames with Firefox

change closing tag from

<iframe …… />

to

<iframe ……></iframe>

It might be that firefox assumes an iframe has content, and therefore doesn’t consider the tag closed.

Automatic Property is the default snippet VS2008

Type prop and hit “tab” twice, this will bring the automatic property

Change GMap2 cursor after initialization

On GMap2 seem map.getDragObject().setDraggableCursor(”crosshair”);  not work on firefox

solution is here:

http://www.teohuiming.name/toydimap/sandbox/change-map-cursor.html

Add .flv file type in IIS

Because by default, IIS does not support FLV or Flash video files.

fix by:

1) Select the site to configure in IIS, right click and select “Properties”
2) Under HTTP Headers Tab, select “File Types” under the MIME Map section and select “New Type”
3) Type “.flv” as the associated extension and “video/x-flv” as the content type.
4) Select “OK”

Change mouse type in Google map api

// GMap2

function changeMouse()
{
map.getDragObject().setDraggableCursor(”crosshair”);

}

function resetMouse()
{
map.getDragObject().setDraggableCursor(”");
}

ref: http://econym.org.uk/gmap/cursors.htm

// old version

function changeMouse()
{
map.setOptions({ draggableCursor: ‘crosshair’ });
}

function resetMouse()
{
map.setOptions({ draggableCursor: ” });
}

ref: http://stackoverflow.com/questions/2557679/how-do-i-change-the-mouse-cursor-when-i-mouseover-on-a-particular-area-in-google

Remove array from index (javascript)

for (var i = overlayPlacemarkTemp.length-1;  i >= 0; i–)
{
if (overlayPlacemarkTemp[i].getIcon().image.indexOf(pt) != -1)
{
// map === remove overlay
myGMap.removeOverlay(overlayPlacemarkTemp[i]);
// remove []
overlayPlacemark.remove(i);
//overlayPlacemarkTemp.length = overlayPlacemarkTemp.length – 1;
}
}

Add, remove elements from javascript array

var arr = [1,2,3];

arr.push(4); //Adds new elements to the end of an array, and returns the new length, result arr = [1,2,3,4];
arr.pop(); //Removes the last element of an array, and returns that element, result arr = [1,2];
arr.length = 0; // remove all element

Set dropdownlist

function setDropDownList(elementRef, valueToSetTo)
{
var isFound = false;

for (var i = 0; i < elementRef.options.length; i++)
{
if (elementRef.options[i].value == valueToSetTo)
{
elementRef.options[i].selected = true;
isFound = true;
}
}

if (isFound == false)
elementRef.options[0].selected = true;

}

Add, remove event in Google map

// add

var map = new GMap2(document.getElementById(”map”));
map.setCenter(new GLatLng(37.4419, -122.1419), 13);
GEvent.addListener(map, “click”, function() {
alert(”You clicked the map.”);
});

// remove

function MyApplication() {
this.counter = 0;
this.map = new GMap2(document.getElementById(”map”));
this.map.setCenter(new GLatLng(37.4419, -122.1419), 13);
var myEventListener = GEvent.bind(this.map, “click”, this, function(overlay, latlng) {
if (this.counter == 0) {
if (latlng) {
this.map.addOverlay(new GMarker(latlng))
this.counter++;
} else if (overlay instanceof GMarker) {
this.removeOverlay(marker)
}
} else {
GEvent.removeListener(myEventListener);
}
});
}

ref: http://code.google.com/intl/th-TH/apis/maps/documentation/events.html

String.Format() In JavaScript like C#

function StringFormat(str)
{

for (i = 1; i < arguments.length; i++)
{
str = str.replace(’{’ + (i – 1) + ‘}’, arguments[i]);
}
return str;
}

example using:
var greeting = format(‘Hello {0} & {1} ‘, ‘John’, ‘Jane’);

ref: http://xneuron.wordpress.com/2006/09/29/stringformat-in-javascript-as-in-c/