Easy to Use Google Maps with GPlotter
July 24th, 2005I have completed GPlotter. It is a very simple Javascript object which can read an XML file to map markers onto a Google Map. I chose to do it this way after initially updating a Google Map using a lot of Javascript which I felt was too easy to break. It is much easier and reliable to generate XML instead of Javascript, so this approach seemed the right way to go. I have posted GPlotter as version 0.5 and hope to add more features and publish new releases soon.
Currently the interface is very simple. Simply run the following Javascript.
var plotter = new GPlotter();
plotter.plot("map", "links", "locations.xml");
Optionally some properties can change, such as the color and the location of the map icons. GPlotter works with the icons I created which come in red, green and blue numbering 1 to 25. The default location for the map icons is /maps/icons/ but can be set with setIconUrl(). See the source code of the example page for GPlotter for all of the details. Check back here for future releases. And if you feel you have some ideas for features, please post a comment here.
I have several ideas for using GPlotter and the XML file format. For starters the XML file is a great way to represent an address book. The address books could include various groups, like locations for favorite restaurants, bars and coffee shops.
Also, the locations file could also be a meta reference on web pages. A Firefox extension could detect the meta value and open a website with a references to the mapping file to plot those locations. On the typical company website with a locations page listing multiples offices this could be used to quickly provide an interactive map to each office. Non-business uses could include maps for public parks or golf courses.
I have many other ideas and I hope to make time to implement them soon.
July 25th, 2005 at 1:43 pm
very cool! I was trying to figure out how to do this yesterday with the Google Tutorial, and it seemed that it really wasn't covered. This function makes it very simple! Now if only I could find a way to create the xml automatically
- Dave
July 25th, 2005 at 4:30 pm
I am working on that next. The hard part is parsing the Tiger data which has all of the mapping data for the US. Then I should be able to get the lat/long coordinates from the database. Ultimately I would like to provide a web service (REST actually) to provide the ability to query that sort of data.
July 25th, 2005 at 4:44 pm
Brennan,
This is awesome. Thanks for providing such a great script. I'm having a couple of problems implementing and am sure there are simple solutions. 1.)The map isn't actually displaying. I get the frame for the google map but no actual map. Ideas? 2.)The map displays above my drop-down navigation, making it unusable. I tried to fix it by adjusting the z-index but no dice.
@Dave: I ran across this bit of PHP that you might find useful. It creates xml automatically. http://www.developerfusion.co.uk/show/3944/
Thanks again.
Ryan
July 26th, 2005 at 6:16 am
Brennan
Great code! I am trying to show the address details without any luck. I know the details are there in the xml but I can't figurre out how to show them on screen. This would help loads.
Many Thanks
Andy [UK]
July 26th, 2005 at 11:59 am
I plan to add those details soon, possibly with some additions to the XML file to allow for more data, such as an option website address and image.
July 27th, 2005 at 9:50 am
I'm not sure what you are doing for lat/lon, but your demo map on the GPlotter site is way off for two of the three locations. The White House and Washington Monument are each miles off (3.4 for the White House, 2.8 miles for the Washington Monument). The Lincoln Memorial is not too far off, since the marker points at the ring road around the Memorial. It'd be nice if the demo of your cool mash-up used accurate data.
July 28th, 2005 at 9:05 am
Awesome! I was about to undertake a project to map out forum subscribers on a world map, when I ran across a link to your site from an Ajax blog. Great work, and I look forward to trying out the API you have graciously shared. I will report back with a link of its use when completed.