Hi Gunther- Please post a link to the full code in the future; right now I can't see what icon_home is equal to so I can't debug fully. I believe what you want is shown in the source code for the marker playground - embedding images and using them as icons: http://gmaps-samples-flash.googlecode.com/svn/trunk/demos/MarkerOptionsPlayground/srcview/index.html
You can also dynamically load in the icons for the markers, and that's shown in this demo: http://gmaps-samples-flash.googlecode.com/svn/trunk/demos/MapMarkersIcons/srcview/index.html - pamela On Tue, Jan 20, 2009 at 11:54 PM, discman <[email protected]> wrote: > > Hi everybody, so my first post here, I didnt find a solutions that > fits my problem (only to rewrite everything), so I am new to Flex as > many and also first time I use Google Map with it. > So first of all I have a few Flex buttons on the bottom and when I > click on the first which is called "Home" I get XML out of a php > script (connects to database, rewrites everything in fine XML data). > > So here is the code: > > First I read out the XML from PHP by giving the PHP-Script a value so > that it knows what button is clicked to get the correct data. > Then later in readXML i create Markers for each XML entry (in the > first case "home" its just one entry of course) > I create the markers and also want to set a MarkerOption so that > every > marker has it. > The problem is that something like marker_options.hasShadow = false; > works but the custom icons doesnt work! The marker just dont come up/ > the icon wont be displayed on the map. > > public function getXml(whatMarker:String):void > { > var xmlString:URLRequest = new URLRequest > ("get_marker.php? > whatMarker=" + whatMarker + ""); > var xmlLoader:URLLoader = new URLLoader > (xmlString); > xmlLoader.addEventListener("complete", > readXml); > } > public function readXml(event:Event):void > { > var markersXML:XML = new XML(event.target.data); > var markers:XMLList = markersXML.marker; > for (var i:Number = 0; i < markers.length(); i+ > +) > { > var marker:XML = markers[i]; > var latlng:LatLng = new LatLng > (mark...@lat, mark...@lng); > map.addOverlay(createMarker(latlng)); > } > } > public function createMarker(latlng:LatLng): Marker > { > var marker:Marker = new Marker(latlng); > marker.setOptions(setMarkerOptions(marker)); > return marker; > } > public function setMarkerOptions > (marker:Marker):MarkerOptions > { > var marker_options:MarkerOptions = new > MarkerOptions(); > marker_options.hasShadow = false; > //marker_options.icon = this.icon_home; > return marker_options; > } > > The string var called whatMarker has the value "home" when I click on > the button home. The custom icons are saved in the same folder as the > swf all in the same style: > home_icon.png > So I want to set the correct icon depending on the clicked button if > I > click the button events i want the markers to have the icon: > events_icon.png > and so on... > so in fact I cant get it done to use something like > marker_options.icon = whatMarker + "_icon.png"; > I also tried to create an flex Image for each marker and assign it to > the marker_options.icon but that also didnt work...I really dont know > any way to get it done! > Maybe someone could be so kind and help me out so that I dont have to > rewrite most of the code here, I found many entries about custom > markers but nothing seem to fit my problem. Also trying to find the > problem with given solutions on custom markers had no effect. > > So the map is situated in a canvas so thats the code for the map > itself: > > > <mx:Canvas id="map_canvas" width="1024" height="568"> > <ns1:Map xmlns:maps="com.google.maps.*" > mapevent_mappreinitialize="onMapPreinitialize(event)" id="map" > width="1024" height="568" key="api_key"/> > <mx:Image source="@Embed('control_zoom_in.png')" > id="zoom_in" > x="10" y="10" buttonMode="true" click="mapControl(event, 0)"/> > <mx:Image source="@Embed('control_zoom_out.png')" > id="zoom_out" > x="10" y="50" buttonMode="true" click="mapControl(event, 1)"/> > </mx:Canvas> > > > Thank you so much!!! > Günther > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
