Re: Marker display preference
Working on a test server that doesn't have an external facing. So here
is some of the code that I have so far. Keep in mind that I've added
several things based on "cool" features that I've found here ;) Here
are the main two functions:
function createTabbedMarker(point,icon,name,htmldisplay){
var marker = new GMarker(point,icon);
marker.setZindex(marker_num);
var pharmacyloc = point.y + ',' + point.x + '"("' + name + '")"';
markers[marker_num] = marker;
page1s[marker_num] = '<p class="rxmaptext">' + name + htmldisplay +
'</p>';
label1s[marker_num] = 'Info';
page2s[marker_num] = '<form action="http://maps.google.com/maps"
method="get" target="_blank" onSubmit="return checkform(this)">' +
'<input type="text" size="40" maxlength="100" name="mystreet"
id="mystreet" class="rxmaptext"/><br/>' +
'<input type="text" size="20" maxlength="100" name="mycity"
id="mycity" value="' + strCity + '" class="rxmaptext"/> ' +
'<input type="text" size="2" maxlength="2" name="mystate"
id="mystate" value="' + strState + '" class="rxmaptext"/>, ' +
'<input type="text" size="5" maxlength="5" name="myzip" id="myzip"
value="' + strZip + '" class="rxmaptext"/>' +
'<br/>' +
'<input type="submit" value="Get Directions" class="rxmaptext"/>' +
'<input type="hidden" name="daddr" value="' + pharmacyloc + '"/>' +
'<input type="hidden" name="saddr" value=""/>' +
'</form>';
label2s[marker_num] = 'Directions';
var i = marker_num;
var html = make_tab(i,1);
aryhtml[marker_num] = html;
GEvent.addListener(marker, "click", function(){
marker_num = i;
markers[marker_num].openInfoWindowHtml(html);
});
sidebar_html += '<font face="Verdana, Arial, Helvetica, sans-serif"
size="1"><a href="#map" onclick="myclick(' + marker_num + ')">' + name
+ '</a>' + htmldisplay + '</font><br/>';
marker_num++;
return marker;
}
// create the map
function MakeMap() {
map = new GMap(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.centerAndZoom(new GPoint(<xsl:value-of select="$latandlng"/>), 1);
var points = new Array();
<xsl:for-each select="//drugstores/drugstore">
// obtain the attribues of each marker
var point = new GPoint(<xsl:value-of select="long"/>, <xsl:value-of
select="lat"/>);
points.push(point);
var htmldisplay = "<br/><xsl:value-of
select="phone"/><br/><xsl:value-of select="address"/>";
var label = "<xsl:value-of select="pharmacy"/>";
var icon = <xsl:choose><xsl:when test="preferred =
'Y'">red_icon</xsl:when><xsl:otherwise>blue_icon</xsl:otherwise></xsl:choose>
// create the marker
var marker = createTabbedMarker(point,icon,label,htmldisplay);
map.addOverlay(marker);
// put the assembled sidebar_html contents into the sidebar div
</xsl:for-each>
document.getElementById("sidebar").innerHTML = sidebar_html;
iw = map.getInfoWindow();
iw.addContext("iwstate", update_tabs);
iw.addContext("iwnavigate", dummy_function);
var bounds = new GBounds(Number.MAX_VALUE, Number.MAX_VALUE,
-Number.MAX_VALUE, -Number.MAX_VALUE);
// extend the bounds to include all the points.
for (var x in points){
bounds.extend(points[x]);
}
// center and zoom on the bounds.
map.centerAndZoomOnBounds(bounds);
}
0 Comments:
Yorum Gönder
<< Home