# HG changeset patch # User Matti Hamalainen # Date 1394594286 -7200 # Node ID 1307410acf6da7d2db2aaea934e2817dec137887 # Parent 20958bb31ee69eadb14102bf49189b70cb819cdc Simplify by getting rid of one wrapper function. diff -r 20958bb31ee6 -r 1307410acf6d markers.js --- a/markers.js Wed Mar 12 04:52:46 2014 +0200 +++ b/markers.js Wed Mar 12 05:18:06 2014 +0200 @@ -82,16 +82,23 @@ } -function pmapCreateMarker(point,name,html,icon,type,continent,mclass) +function pmapCreateMarker(m, mclass) { - pname = (type != "default" ? type.toUpperCase()+" " : "") + name; + type = pmapLocGetLocationType(m["flags"], m["type"]); + if (m["name"].indexOf('FERRY') == 0) + type = "ferry"; + + pname = (type != "default" ? type.toUpperCase()+" " : "") + m["name"]; + + if (m["flags"] & LOCF_CLOSED) + pname += " (CLOSED)"; var marker = new MarkerWithLabel( { - position: point, - icon: icon, + position: pmapMapCoordsToLatLng(new google.maps.Point(m["x"] * 2 + 1, m["y"] * 2 + 1), 7), + icon: pmapIcons[type], draggable: false, - labelContent: name, + labelContent: m["name"], labelAnchor: new google.maps.Point(22, 0), labelClass: "labels", labelStyle: {opacity: 0.75} @@ -99,34 +106,24 @@ google.maps.event.addListener(marker, "click", function() { - pmapInfoWindow.setContent("
"+html+"
"); + pmapInfoWindow.setContent("
"+ m["html"] +"
"); pmapInfoWindow.open(pmap, this); }); - if (mclass == "builtin") pmapSideBuiltinHTML += '
 
'+ pname +'
'; + if (mclass == "builtin") pmapSideBuiltinHTML += '
 
'+ pname +'
'; if (mclass == "private") pmapSidePrivateHTML += '' + pname + '
'; if (mclass == "public") pmapSidePublicHTML += '' + pname + '
'; pmapMarkers[pmapMIndex] = marker; - pmapMarkerInfo[pmapMIndex] = [type, continent]; + pmapMarkerInfo[pmapMIndex] = [type, m["continent"]]; pmapMIndex++; - return marker; -} - - -function pmapCreateMarkerType(m, mclass) -{ - type = pmapLocGetLocationType(m["flags"], m["type"]); - if (m["name"].indexOf('FERRY') == 0) - type = "FERRY"; - - var ppos = pmapMapCoordsToLatLng(new google.maps.Point(m["x"] * 2 + 1, m["y"] * 2 + 1), 7); - var marker = pmapCreateMarker(ppos, m["name"], m["html"], pmapIcons[type], type, m["continent"], mclass); if (pmapAreas[type] == undefined) pmapAreas[type] = []; pmapAreas[type].push(marker); + + return marker; } @@ -165,7 +162,7 @@ for (var nid = 0; nid < markers.length; nid++) { - pmapCreateMarkerType(markers[nid], "builtin"); + pmapCreateMarker(markers[nid], "builtin"); } pmapAddMarkers(pmapAreas["default"], 7, 11); @@ -192,7 +189,7 @@ for (var nid = 0; nid < markers.length; nid++) { - pmapCreateMarkerType(markers[nid], "tradelane"); + pmapCreateMarker(markers[nid], "tradelane"); } pmapAddMarkers(pmapAreas["tradelane"], 5, 11);