I'm using Pamela Fox's "Toggling Marker Categories" demonstration for
a find a cup utility at he Coda Coffee website.

http://www.codacoffee.com/site/findacup.html

(choose the grey graphic of the US) The markers for the Colorado
state will periodically not plot. This is pretty frustrating as we've
just launched a print campaign driving traffic to this map feature.

I've attempted to use the zoom levels to try and get better results
(because many of the markers are condensed in the downtown area). But
only minor improvements; if any at all.

I'm not using external styles sheets or anything like that. I have
seen the markers fail on Firefox as well... Happens mostly with IE7
and IE8.

There are approximately 65 addresses being plotted for the state of
Colorado. All other states have 1-5 addresses and there are no issues
so far with the other states; just Colorado.

The site is hosted through a NetSuite eCommerce platform. I'm calling
the supporting XML file with the addresses using a local path
reference.

Here's the code:

import com.google.maps.LatLng;
import com.google.maps.LatLngBounds;
import com.google.maps.Map;
import com.google.maps.MapEvent;
import com.google.maps.MapMouseEvent;
import com.google.maps.MapType;
import com.google.maps.overlays.Marker;
import com.google.maps.overlays.MarkerOptions;
import com.google.maps.InfoWindowOptions;
import com.google.maps.styles.FillStyle;
import com.google.maps.controls.ZoomControl;
import com.google.maps.controls.PositionControl;
import com.google.maps.controls.MapTypeControl;

var myTf:TextFormat = new TextFormat();
myTf.color = 0xf37021;
myTf.size = 12;

homeCB.setStyle("textFormat", myTf);
restaurantsCB.setStyle("textFormat", myTf);
cafesCB.setStyle("textFormat", myTf);
bakeriesCB.setStyle("textFormat", myTf);
marketsCB.setStyle("textFormat", myTf);
specialtyStoresCB.setStyle("textFormat", myTf);


var categories:Object =
{ "Restaurant": {
    "color": 0xf26730,
    "markers": []},
  "Cafe": {
    "color": 0xf28a61,
    "markers": []},
  "Bakery": {
    "color": 0xf29b79,
    "markers": []},
  "Market": {
    "color": 0xf2ad91,
    "markers": []},
  "SS": {
    "color": 0xf2beaa,
    "markers": []},
  "Home": {
    "color": 0xf14500,
    "markers": []}
};

var map:Map = new Map();
//key for domain: http://www.codacoffee.com
map.key = "ABQIAAAAew2XsptGhsGVbO95wPuN8BTp-
b_vC6pj-770xDR73IXlBPYkdhQ6rlh6uwhj9VxGx220rBVaxn-g_A";

//key for domain: http://shopping.netsuite.com/
//map.key =
"ABQIAAAAYZ72ctj9Whyzgi4fPkjr7xSci3qjfiDTudW3RwHinauI91AmMRRkxAfwHDQ52Y-
dugVTxSOlDOA46g"

map.x = 200;
map.y = 0;
map.setSize(new Point(stage.stageWidth-200, stage.stageHeight));
map.addEventListener(MapEvent.MAP_READY, onMapReady);
this.addChild(map);

restaurantsCB.addEventListener(MouseEvent.CLICK, function(e:Event) {
  toggleCategory("Restaurant");
});
cafesCB.addEventListener(MouseEvent.CLICK, function(e:Event) {
  toggleCategory("Cafe");
});
bakeriesCB.addEventListener(MouseEvent.CLICK, function(e:Event) {
  toggleCategory("Bakery");
});
marketsCB.addEventListener(MouseEvent.CLICK, function(e:Event) {
  toggleCategory("Market");
});
specialtyStoresCB.addEventListener(MouseEvent.CLICK, function(e:Event)
{
  toggleCategory("SS");
});
homeCB.addEventListener(MouseEvent.CLICK, function(e:Event) {
  toggleCategory("Home");
});

/*CO*/ whichStateHdr.text = "COLORADO";
///*FL*/ whichStateHdr.text = "FLORIDA";
///*VA*/ whichStateHdr.text = "VIRGINIA";
///*MI*/ whichStateHdr.text = "MICHIGAN";
///*TN*/ whichStateHdr.text = "TENNESSEE";
///*SD*/ whichStateHdr.text = "SOUTH DAKOTA";
///*WA*/ whichStateHdr.text = "WASHINGTON STATE";
///*ID*/ whichStateHdr.text = "IDAHO";
///*PA*/ whichStateHdr.text = "PENNSYLVANIA";

function onMapReady(event:Event):void {
  map.enableScrollWheelZoom();
  map.enableContinuousZoom();
  /*CO*/  map.setCenter(new LatLng(39.739010, -104.990373), 11,
MapType.PHYSICAL_MAP_TYPE);
//  /*FL*/map.setCenter(new LatLng(29.051469, -82.037966), 8,
MapType.PHYSICAL_MAP_TYPE);
//  /*VA*/map.setCenter(new LatLng(37.767721, -76.454631), 7,
MapType.PHYSICAL_MAP_TYPE);
//  /*MI*/map.setCenter(new LatLng(45.062657, -83.433535), 7,
MapType.PHYSICAL_MAP_TYPE);
//  /*TN*/map.setCenter(new LatLng(35.547956, -87.553821), 7,
MapType.PHYSICAL_MAP_TYPE);
//  /*SD*/map.setCenter(new LatLng(44.131709, -103.071493), 7,
MapType.PHYSICAL_MAP_TYPE);
//  /*WA*/map.setCenter(new LatLng(48.284862, -117.731925), 7,
MapType.PHYSICAL_MAP_TYPE);
//  /*ID*/map.setCenter(new LatLng(43.585281, -116.193744), 7,
MapType.PHYSICAL_MAP_TYPE);
//  /*PA*/map.setCenter(new LatLng(40.690409, -76.257688), 7,
MapType.PHYSICAL_MAP_TYPE);

  map.addControl(new ZoomControl());
  map.addControl(new PositionControl());
  map.addControl(new MapTypeControl());

  /*CO*/var xmlString:URLRequest = new URLRequest("xmlPacks/
coda_co_stores_v2.xml");
//  /*FL*/var xmlString:URLRequest = new URLRequest("xmlPacks/
coda_fl_stores_v2.xml");
//  /*VA*/var xmlString:URLRequest = new URLRequest("xmlPacks/
coda_va_stores_v2.xml");
//  /*MI*/var xmlString:URLRequest = new URLRequest("xmlPacks/
coda_mi_stores_v2.xml");
//  /*TN*/var xmlString:URLRequest = new URLRequest("xmlPacks/
coda_tn_stores_v2.xml");
//  /*SD*/var xmlString:URLRequest = new URLRequest("xmlPacks/
coda_sd_stores_v2.xml");
//  /*WA*/var xmlString:URLRequest = new URLRequest("xmlPacks/
coda_wa_stores_v2.xml");
//  /*ID*/var xmlString:URLRequest = new URLRequest("xmlPacks/
coda_id_stores_v2.xml");
//  /*PA*/var xmlString:URLRequest = new URLRequest("xmlPacks/
coda_pa_stores_v2.xml");

  var xmlLoader:URLLoader = new URLLoader(xmlString);
  xmlLoader.addEventListener("complete", readXml);
}

function readXml(event:Event):void{
  var markersXML:XML = new XML(event.target.data);
  var markers:XMLList = markersXML..marker;
  var markersCount:int = markers.length();

  for (var i:Number = 0; i < markersCount; i++) {
          trace(i);
        var marker:XML = markers[i];
    var name:String = mark...@name;
    var address:String = mark...@address;
    var website:String = mark...@website;
        var latlng:LatLng = new LatLng(mark...@lat, mark...@lng);
    var type:String = mark...@type;
      createMarker(latlng, name, address, website, type);
    }
}


function createMarker(latlng:LatLng, name:String, address:String,
website:String, type:String):void {
  var markerOptions:MarkerOptions = new MarkerOptions({});
  var fillStyle:FillStyle = new FillStyle({color: categories
[type].color});
  markerOptions.fillStyle = fillStyle;
  var marker:Marker = new Marker(latlng, markerOptions);
  var html:String = "<font face='Verdana'><b><a href='"+ website +"'
target='_blank'><font color='#f15d22'>" + name + "</font></a></b><br/
>" + address + "</font>";
  marker.addEventListener(MapMouseEvent.CLICK, function
(e:MapMouseEvent):void {
    marker.openInfoWindow(new InfoWindowOptions({contentHTML:html}));
  });
  categories[type].markers.push(marker);
  map.addOverlay(marker);
 }

function toggleCategory(type:String):void {
  for (var i:Number = 0; i < categories[type].markers.length; i++) {
    var marker:Marker = categories[type].markers[i];
    if (!marker.visible) {
      marker.visible = true;
    } else {
      marker.visible = false;
    }
  }
}


stop();


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API For Flash" 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-for-flash?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to