Resize the markers in google maps

When we use the default markers and sometimes we need to resize the markers in google maps

and here is the code to resize icon image


var pinIcon = new google.maps.MarkerImage(
    "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|FFFF00",
    null, /* size is determined at runtime */
    null, /* origin is 0,0 */
    null, /* anchor is bottom center of the scaled image */
    new google.maps.Size(42, 68)
);  

the icon for example

Resize the markers in google maps

So this will help you to know how to Resize the markers in google maps

Adding custom infowindow in google maps API

If we need to modify the normal info window that is provided by google..ie if we are looking for adding custom infowindow in google maps api We have to utilize the infobox to do so

The first example shows the custom info window

var marker = new google.maps.Marker({
         map: theMap,
         draggable: true,
         position: new google.maps.LatLng(49.47216, -123.76307),
         visible: true
        });
                
        var boxText = document.createElement("div");
        boxText.style.cssText = "border: 1px solid black; margin-top: 8px; background: yellow; padding: 5px;";
        boxText.innerHTML = "City Hall, Sechelt<br>British Columbia<br>Canada";
                
        var myOptions = {
                 content: boxText
                ,disableAutoPan: false
                ,maxWidth: 0
                ,pixelOffset: new google.maps.Size(-140, 0)
                ,zIndex: null
                ,boxStyle: { 
                  background: "url('tipbox.gif') no-repeat"
                  ,opacity: 0.75
                  ,width: "280px"
                 }
                ,closeBoxMargin: "10px 2px 2px 2px"
                ,closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif"
                ,infoBoxClearance: new google.maps.Size(1, 1)
                ,isHidden: false
                ,pane: "floatPane"
                ,enableEventPropagation: false
        };

        var ib = new InfoBox(myOptions);
        ib.open(theMap, marker);

and another one is to use the infobox to create label in maps

var labelText = "City Hall";

        var myOptions = {
                 content: labelText
                ,boxStyle: {
                   border: "1px solid black"
                  ,textAlign: "center"
                  ,fontSize: "8pt"
                  ,width: "50px"
                 }
                ,disableAutoPan: true
                ,pixelOffset: new google.maps.Size(-25, 0)
                ,position: new google.maps.LatLng(49.47216, -123.76307)
                ,closeBoxURL: ""
                ,isHidden: false
                ,pane: "mapPane"
                ,enableEventPropagation: true
        };

        var ibLabel = new InfoBox(myOptions);
        ibLabel.open(map);

Hopping that this articles helps you to know adding custom infowindow in google maps API

Sort an array based on a key in php

When dealing with php array we sometimes needs sorting functionality.if we want to sort an array based on a key in php here is the function which helps you to do so.

<?php
function subval_sort($array,$subkey,$sr) 
{
	
	foreach($array as $k=>$v) {
		$b[$k] = strtolower($v[$subkey]);
	}
	if($sr=='asc'){
	asort($b);}
	else{arsort($b);}
	foreach($b as $key=>$val) {
		$c[] = $a[$key];
}
	return $c;
}
?>

here,
$array is the array to be sorted.
$subkey is the key.
$sr is the order asc or desc.