javascript - Mapstraction: Changing an Icon's image URL after it has been added? -
i trying use marker.seticon()
change markers image. appears although changes marker.iconurl
attribute icon using marker.proprietary_marker.$.icon.image
display markers image - markers icon remains unchanged. there way dynamically change marker.proprietary_marker.$.icon.image
?
- add marker.
- check icon's image url , proprietary icon's image - they're same.
- change icon.
- again check urls. icon url has changed marker still shows old image in proprietary marker object.
<head> <title>map test</title> <script src="http://maps.google.com/maps?file=api&v=2&key=your-google-api-key" type="text/javascript"></script> <script src="mapstraction.js"></script> <script type="text/javascript"> var map; var marker; function getmap(){ map = new mxn.mapstraction('mymap','google'); map.setcenterandzoom(new mxn.latlonpoint(45.559242,-122.636467), 15); } function addmarker(){ marker = new mxn.marker(new mxn.latlonpoint(45.559242, -122.636467)); marker.adddata({infobubble : "text", label : "label", marker : 4, icon: "http://mapscripting.com/examples/mashups/richter-high.png"}); map.addmarker(marker); } function changeicon(){ marker.seticon("http://assets1.mapufacture.com/images/markers/usgs_marker.png"); } function showiconurl(){ alert(marker.iconurl); } function showproprietaryiconurl(){ alert(marker.proprietary_marker.$.icon.image); } </script> </head> <body onload="getmap()"> <div id="mymap" style="width:627px; height:412px;"></div> <div> <input type="button" value="add marker" onclick="addmarker();"> <input type="button" value="change icon" onclick="changeicon();"> <input type="button" value="show icon url" onclick="showiconurl();"> <input type="button" value="show proprierty icon url " onclick="showproprietaryiconurl();"> </div> </body> </html>
it understanding have read once create marker can no longer change "icon" of marker. can change image property of marker have read don't believe possible change through icon options once marker has been generated.
i believe read if change image of icon maintain same size properties set in icon settings marker options. ie if first image set 15x15 , second 5x5 5x5 resized 15x15.
Comments
Post a Comment