/ Published in: JavaScript
URL: http://img140.imageshack.us/i/googleidea.jpg/
Hi, I want to share my Code with the custom Icon for StreetView on the Map2. This Icon show the ViewPoint on the map.
Like: (http://img140.imageshack.us/img140/5558/googleidea.jpg "Perview")
The Source Route:- Get the CSS-Style Objekt form the GMarker on Map2 add put a CSS Background Image.
- Change the CSS-Style Objekt if fire a GEvent:yawchanged from StreetView.
First we need the Orginal Image: http://maps.gstatic.com/intl/deALL/mapfiles/cb/modcbscout/cbscoutsprite003.png. Than we need a Transparnt Pix with size: 49px x 52px.
Expand |
Embed | Plain Text
/* Initialize GIcon: */ { var gIcon = new GIcon(); gIcon.image = "Transparnt.png"; gIcon.iconSize = new GSize(49, 52); gIcon.iconAnchor = new GPoint(24, 33); } /* Initialize GMarker: */ { var StvMarker = new GMarker(new GLatLng(x, y), {icon: gIcon}); // This is importet to set a id to find later the DOM-Objekt, // and Google set automatic a prefix 'mtgt_' StvMarker.id = "streetViewMan"; map.addOverlay(StvMarker); } /* Initialize GEvent: */ { var myPano = new GStreetviewPanorama(document.getElementById('streetView'), svOpts); GEvent.addListener(myPano, "yawchanged", function(yaw) {setCSSStyleIcon(yaw)} ); } /* AND NOW THE REALY CODE */ function setCSSStyleIcon(yaw) { var iconMapURL = 'http://maps.gstatic.com/intl/de_ALL/mapfiles/cb/mod_cb_scout/cb_scout_sprite_003.png'; //All the 16 Image Postion in iconMapURL var PicPx = [ [-49, -711], // N [-00, -34],// NNO [-98, -711], // NO [-98, -365], // ONO [-00, -365], // O [-98, -417], // OSO [-98, -313], // SO [-98, -797], // SSO [-98, -150], // S [-00, -711], // SSW [-00, -417], // SW [-98, -000], // WSW [-49, -365], // W [-49, -417], // WNW [-49, -849], // NW [-00, -849]// NNW ]; var PicPos = PicPx[ Math.floor( yaw / 22.5 ) ]; //360 degree / 16 Images = 22.5 degree document.getElementById('mtgt_streetViewMan').style.background = "url("+iconMapURL+") "+PicPos[0]+"px "+PicPos[1]+"px"; }
Comments
Subscribe to comments
You need to login to post a comment.

Hi, I want to share my Code with the custom Icon for StreetView on the Map2. This Icon show the ViewPoint on the map.
Like:
The Source Route:
First we need the Orginal Image: http://maps.gstatic.com/intl/deALL/mapfiles/cb/modcbscout/cbscoutsprite003.png. Than we need a Transparnt Pix with size: 49px x 52px.