Ok, I got MTYahooMaps plugin to work for Individual Entries and Category pages, but the Daily, Weekly and Monthly archives get all screwed up. I’ve tracked down the problem to the fact that when a Plugin gets called an Archive Context, there is no Entry to reference.
That is, when pulling an Entry from the context stash, No entry is returned, but you can get the Entries (multiple) out of the context stash. By going thru each Entry Text, I can determine which Entries being need MTYahooMap written for them but not Which one is currently being called.
To make things even more entertaining, I don’t want to assume that the page will be written with the Latest Entry at the Top, oldest at the Bottom.
Once I have an Array of Entries, I need to order the array by Creation Date. The question then is: Ascending or Descending? This is done via the Blog "sort_order_posts" setting which is accesable via the PERL API.
This should be two Yahoo Maps, The Top is of 11 Madison Avenue The Bottom is of 499 Park Avenue.
Update: Well, it works Only on the Individual Archive page. For Now, No Multiple Maps on One Post. So, I pulled the 499 park Avenue Map.
Update: Seems I got it. The Above Maps show up in all Archive types properly.
Ok, I got Both MTGoogleMaps and my New Plugin MTYahooMaps Working in both I.E. and Firefox. Can They work in the Same Post? On the Left will Hopefully be a Google Map of 11 Madison Avenue, on the Right, A Yahoo Ajax Map of 11 Madison Avenue…
Update: In Internet Explorer ONLY, Some of the Post shows up Between the Images. It’s a DIV problem solved by a clear:both. To make sure Everyone can see the two Maps, I put it at the Bottom.
Last Update: It works perfectly. I’ve added Latitude and Longitude Parameters since I was a little unhappy where the Geocoder put 11 Madison Avenue. This comming week, I’ll write the documentation for it.
These two maps were made with this Code Strung together:
<MTGoogleMaps address=”11 Madison avenue,NY, NY, 10010″
info=”A Nice Place”
width=”273″ height=”300″ zoom=”2″
<MTYahooMaps address=”11 Madison avenue,NY, NY, 10010″
info=”A Nice Place”
width=”273″ height=”300″ zoom=”3″
With a Little luck, this will be a Flash Based Yahoo Map in an Iframe. It will have a Marker for 11 Madison Avenue and a Closed Nav widget… BooYah!
Ok, a lot of issues came up when using Google Maps or Yahoo Maps inside a DIV Boundary:
- Google Maps and Internet Explorer blows up Every single time it’s inside DIV Boundaries.
- Yahoo Maps Beta gets inconsistent results when it shares the same page with Multiple Yahoo Maps and with I.E.
- Yahoo Maps and Google Maps will NOT coexist on the same HTML file.
Solution: Write the Map HTML to it’s own HTML File and include it on the page via a IFRAME.
Sounds simple but it’s a little tricky. MT loads the plugins with mt.cgi in the same memory space and invokes the same plugin for different context. That is, the same plugin with the same Values Multiple times for everywhere it is needed. This means that unless you are careful, you’ll write out the same Map HTML file multiple times.
With a little careful PERL coding, we avoid that and write out the file alongside the Individual Archive File in the same Directory. This has a bonus for me: This was very educational and I’ve gained a good understanding of how MT Plugins work and how to code for them in PERL.
- Add loging via the MT::Log Module. There really should be a log entry telling the Admin what new files have been created. Operationaly, it’s a good idea.
- Add error catching if the Geocoder can’t resolve an address. Let’s the User know that it won’t work and a Map will not be produced. Also Add Error Catching to qualify the parameters passed to the plugin.
- Add Longitude and Latitude parameters in case the user does not have an address but used the many Geocoders on the Internet to get one.
- Add Multiple Markers on the Map.
- PolyLine area support.
When I’m sure the Bugs are all gone, I’ll send Nick Punter both the MTGoogleMap verison and the MTYahooMap version.
Image cut and pasted from Google Maps.
Oddly, it has "Imagery ©2005 State of New Jersey" Even though that is 499 Park Avenue in Manhattan. Is NJ Spying on us??
If this works, I’ll get a Map of 11 Madison Avenue…
Likely it blows up on the first try…
Update 1: Yep, It blew up. Left some important Template variables out of the PERL portion.
Update 2: Added a Flash Template that **STILL** doesn’t work to well in I.E.
Update 3: Will add Browser detection. If it finds a I.E. Browser, It will use Yahoo Maps AJAX version.
Off for Thanksgiving Dinner!
Happy Thanksgiving to All!
It was just clear enough to go for a short walk.
Hopefully, This will be a Map of 499 Park Avenue in both Firefox and Internet Explorer…
Update: Need to fix a “feature”. If you have two MAPS on a page they get the same DIV id. Might use Perl time() function to generate unique ID’s for the Map and Marker ID’s. Ugly, but it would work.
Ok, After some pain, I’ve discovered the following:
- Google MAP and Yahoo Maps BETA *CAN’T* exist in the same HTML (There’s a Shock…)
- When embedded in DIV boundaries The Google Map Works with EVERY Browser I can think of EXCEPT Internet Explorer.
- The Yahoo Maps BETA, does not work properly when used in the Individual Entry Page. Kid you not, the Exact SAME code won’t produce the same results in the Individual Entry Page (It’s Beta, so it’s not expected to work full time. I’m sure Yahoo will fix it)
To get around Problem 1 and 2, I’ve modified the map.tmpl to have PHP code check the browser based on the $_SERVER[‘HTTP_USER_AGENT’] Server Variable. If it picks up the " MSIE " string, it use Yahoo Maps Beta, else Google Maps. It’s Sloppy, a Quick and dirty fix but it works.
For me, I prefer Google Maps as the Satellite imagery or Hybrid is a nice choice but I really don’t care either way. Probably, I’ll modify the PERL code preferences to let the person who manages the MT Blog to decide to use Google Map, Yahoo Map or specify by MTGoogleMap Parameter. Also, you need a Yahoo App ID which should go in the Preferences Section.
UPDATE: After yet even more research, I found that Yahoo Maps BETA has an AJAX version. Other then the Minus on the Zoom bar not working, it’s pretty good. Next step, make it all production ready (i.e. Take out all the Debug stuff), document and Fini.
Well, as a work around, if the Browser is Intenet Explorer, the Entry will use Yahoo Maps Beta.
I suppose the Plugin might have to be renamed a bit.
More tweaking later…