|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
TGKnIght Smarty Junkie
Joined: 07 Sep 2005 Posts: 580 Location: Philadelphia, PA
|
Posted: Wed Nov 30, 2005 6:14 pm Post subject: GoogleMapAPI discussion |
|
|
Ok so I jumped on this as soon as I saw Monte's post. I had read in Popular Science that Google was releasing their mapping interface and was planning on looking into it.. There's all kinds of neat things you can do, for example : http://www.chicagocrime.org
Anyway, my plans are not so grand, I will be utilizing the maps on customer sites to provide directions to their locations.
So I began to integrate Monte's map class into my program, easy as pie!
After a bit of fooling around I have a few things to note :
I altered the width and height to be string variables which can include either 'px' or '%'
Code: |
~~Line 164 in variable declarations
var $width = '500px';
var $height = '500px';
|
In the getMap() method a slight alteration to accomodate by removing the 'px' that was hardcoded into this line :
Code: |
~~Line 719
$_output = sprintf('<div id="%s" style="width: %s; height: %s"></div>',$this->map_id,$this->width,$this->height) . "\n";
|
The next issue was with styling, the stylesheet I had in place mangled the map and all the controls. I fixed this by defining a few new id's in my stylesheet. (PS The ID you want to use in your stylesheet = "map" if you didn't specify a different one when instantiating the map object)
Code: |
#map {
width: 100%;
height : 100%;
padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
}
#map div, #map p {
padding: 0px 0px 0px 0px;
margin: 0px 0px 0px 0px;
background-color: transparent;
}
|
This was good because now the maps were actually sizing to my browser window width-wise.. but height-wise 100% doesn't mean anything apparently
So the next thing to do was create a javascript that dynamically changes the map's (this should work for IE and Moz)
Code: |
/*
Created by : owenc/at/totalsales/dot/com
Date Created : 11/30/2005
Purpose : This script detects the browsers current height and resizes the div with id="map" to that height
Use :
window.onload=gMapSize
window.onresize=gMapSize
*/
function getHeight() {
var myHeight = 0;
if( typeof( window.innerHeight ) == 'number' ) {
//Non-IE
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientHeight || document.documentElement.clientHeight ) ) {
//IE 6+ in 'standards compliant mode'
myHeight = document.documentElement.clientHeight;
} else if( document.body && ( document.body.clientHeight || document.body.clientHeight ) ) {
//IE 4 compatible
myHeight = document.body.clientHeight;
}
return myHeight;
}
function gMapSize () {
mapwidth=getHeight()
mymap=document.getElementById? document.getElementById("map") : document.all.map
mymap.style.height=parseInt(mapwidth)
}
|
and in your html
Code: |
<script language="JavaScript1.2" src="{$Site.js_path}/GoogleMap.js"></script>
<script type="text/javascript">
window.onload=gMapSize
window.onresize=gMapSize
</script>
|
Anyway that's where I'm at thus far. Hope this helps any other developers out there.
Chime in if you are using it! |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Nov 30, 2005 8:12 pm Post subject: |
|
|
I adjusted the library to allow either px or % for the width/height. Thanks for the help! |
|
Back to top |
|
infield Smarty n00b
Joined: 03 Jun 2005 Posts: 4 Location: SF, CA
|
Posted: Thu Feb 16, 2006 9:39 am Post subject: Multiple marker icons |
|
|
Is it possible to create multiple icons and assign each one when the marker is being created with add addMarkerByAddress or addMarkerByCoords?
Also small typo in docs, the addMarkerByCoords example uses addMarkerByAddress function.
Very cool class. Thanks! |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Feb 16, 2006 3:07 pm Post subject: |
|
|
IIRC, you can only set one global icon/shadow for the map markers. This may change when I get a chance to work on it, or someone else beats me to it |
|
Back to top |
|
infield Smarty n00b
Joined: 03 Jun 2005 Posts: 4 Location: SF, CA
|
Posted: Thu Feb 16, 2006 6:52 pm Post subject: |
|
|
I'll try and take a look and make some notes, but I'm a newb.
The other thing I'll try and look into is an auto-size for setZoomLevel() that would set the proper zoom level for a set of markers.
Again a really nice class! |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|