First I’m pretty new to Javascript, so sorry if my question comes across poorly.
I’m creating an application in Flash to help users calculate their electrical costs. Then I’m taking this figure and write it to an xml file.
Now I’m looking to open a webpage and show a google map, and there is a rectangle drawn over the map which is generated dynamically from the number generated earlier and stored in the xml file.
I’m completely lost as to places to turn on how to achieve this. I’ve gotten my map on to my page, and it scales 100% as I want it to, but I can’t figure out the dynamic rectangle part at all. Any ideas or pointers in the right direction greatly appreciated.
In this latest version, the XML file
is loaded as soon as the map tiles finish loading. I could not get the
getProjectionto be called correctly if I did not wait for tile loading to finish. The docs state that getting the projection needs the map to be initialized, and recommends listening forprojection_changed. Both ways work yet I still feel listening to tiles_loaded is safer and if something goes wrong with the xml loading it will get called again if the map is zoomed or panned a noticeable amount.The rectangle is defined by width in points (the whole world is 256×256 points), so some conversion is needed when assigning their centers to the more conventional LatLng.
Finally, a rectangle is created with a country name that goes into a MarkerWithLabel (using v1.1.5 here, you can hotlink to http://google-maps-utility-library-v3.googlecode.com/svn/tags/markerwithlabel/1.1.5/src/markerwithlabel_packed.js though I prefer saving a local copy)
Since dragging a rectangle appears impossible, a marker in its center works as a handle. When it’s dragged, the associated rectangle moves with it.
Styling the labels need to be done both in the .labels CSS class and the constructor, and rectangles have options like stroke color, thickness, opacity, and fill color.