// this will create a global variable 'myIcon'

var myIcon = new GIcon();
myIcon.image = 'markers/image.png';
myIcon.printImage = 'markers/printImage.gif';
myIcon.mozPrintImage = 'markers/mozPrintImage.gif';
myIcon.iconSize = new GSize(35,37);
myIcon.shadow = 'markers/shadow.png';
myIcon.transparent = 'markers/transparent.png';
myIcon.shadowSize = new GSize(54,37);
myIcon.printShadow = 'markers/printShadow.gif';
myIcon.iconAnchor = new GPoint(18,37);
myIcon.infoWindowAnchor = new GPoint(18,0);
myIcon.imageMap =
[18,0,19,1,20,2,21,3,27,4,28,5,28,6,29,7,32,8,33,9,34,10,34,11,34,12,34,13,34,14,34,15,34,16,34,17,34,18,34,19,34,20,34,21,34,22,34,23,34,24,34,25,34,26,34,27,34,28,33,29,31,30,29,31,27,32,26,33,24,34,23,35,21,36,16,36,14,35,12,34,10,33,9,32,8,31,6,30,4,29,2,28,0,27,0,26,0,25,5,24,3,23,2,22,1,21,0,20,0,19,0,18,0,17,0,16,0,15,1,14,1,13,1,12,1,11,1,10,2,9,2,8,3,7,3,6,4,5,5,4,6,3,7,2,9,1,11,0];

if (GBrowserIsCompatible()) {

function createMarker(point,html) {

// here pass the custom icon to the GMarker constructor
var marker = new GMarker(point, {icon:myIcon});

GEvent.addListener(marker, "mouseover", function() {
marker.openInfoWindowHtml(html);

});
return marker;
}

var map = new GMap2(document.getElementById("map"),{mapTypes:
[G_NORMAL_MAP,G_HYBRID_MAP,G_SATELLITE_MAP]});
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(51.000000, -0.200000),10);

var point = new GLatLng(51.400000,-0.206000);
var marker = createMarker(point,'<div style=width:240px><b>hello this
is a test</b></div>')
GEvent.addListener(marker, 'click', function() {
});

map.addOverlay(marker);
var point = new GLatLng(51.4600000,-0.2160000);
var marker = createMarker(point,'<div style=width:240px><b>hello this
is another test</b></div>')
GEvent.addListener(marker, 'click', function() {
});
}

You can see how to pass marker options to the GMarker constructor
here:
http://code.google.com/apis/maps/documentation/javascript/v2/reference.html#GMarker

And the various options are detailed here:
http://code.google.com/apis/maps/documentation/javascript/v2/reference.html#GMarkerOptions

Martin.



On 24 Aug, 14:32, dna <[email protected]> wrote:
> Hi I was hoping someone could help me get a custom icon working with
> this code.
>
> The first part is the code that is working used to display multiple
> icons on the map. The second part is the code I want to use so that
> all the icons display the custom icon instead of the normal red
> pointer.
>
> --------------------------------------------------------------------------------------------------------------------
>
> if (GBrowserIsCompatible()) {
>
> function createMarker(point,html) {
> var marker = new GMarker(point);
> GEvent.addListener(marker, "mouseover", function() {
> marker.openInfoWindowHtml(html);
>
> });
> return marker;
> }
>
> var map = new GMap2(document.getElementById("map"),{mapTypes:
> [G_NORMAL_MAP,G_HYBRID_MAP,G_SATELLITE_MAP]});
> map.addControl(new GLargeMapControl());
> map.addControl(new GMapTypeControl());
> map.setCenter(new GLatLng(51.000000, -0.200000),10);
>
> var point = new GLatLng(51.400000,-0.206000);
> var marker = createMarker(point,'<div style=width:240px><b>hello this
> is a test</b></div>')
> GEvent.addListener(marker, 'click', function() {});
>
> map.addOverlay(marker);
> var point = new GLatLng(51.4600000,-0.2160000);
> var marker = createMarker(point,'<div style=width:240px><b>hello this
> is another test</b></div>')
> GEvent.addListener(marker, 'click', function() {});
> }
>
> ---------------------------------------------------------------------------------------
> And this is the code I believe I need for my customer marker.
> ---------------------------------------------------------------------------------------
>
> var myIcon = new GIcon();
> myIcon.image = 'markers/image.png';
> myIcon.printImage = 'markers/printImage.gif';
> myIcon.mozPrintImage = 'markers/mozPrintImage.gif';
> myIcon.iconSize = new GSize(35,37);
> myIcon.shadow = 'markers/shadow.png';
> myIcon.transparent = 'markers/transparent.png';
> myIcon.shadowSize = new GSize(54,37);
> myIcon.printShadow = 'markers/printShadow.gif';
> myIcon.iconAnchor = new GPoint(18,37);
> myIcon.infoWindowAnchor = new GPoint(18,0);
> myIcon.imageMap =
> [18,0,19,1,20,2,21,3,27,4,28,5,28,6,29,7,32,8,33,9,34,10,34,11,34,12,34,13,34,14,34,15,34,16,34,17,34,18,34,19,34,20,34,21,34,22,34,23,34,24,34,25,34,26,34,27,34,28,33,29,31,30,29,31,27,32,26,33,24,34,23,35,21,36,16,36,14,35,12,34,10,33,9,32,8,31,6,30,4,29,2,28,0,27,0,26,0,25,5,24,3,23,2,22,1,21,0,20,0,19,0,18,0,17,0,16,0,15,1,14,1,13,1,12,1,11,1,10,2,9,2,8,3,7,3,6,4,5,5,4,6,3,7,2,9,1,11,0];
>
> -----------------------------
>
> Thanks for any help in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-api?hl=en.

Reply via email to