bMap - Examples

1. Basic example2. Markers in constructor3. Markers, polylines & polygons
4. Marker sidebar5. Layer Sidebar6. AJAX Layers
7. Advanced AJAX8. Google Functions9. Custom Icons
10. Advanced marker events11. Image Overlay Function12. New sidebar features

Markers and a sidebar:

How its done:

By telling the bMap object to use a sidebar, the sidebar is populated automatically with a clickable div element. Use CSS to style the sidebar, the most recently clicked item has a class added so you can style that too.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="http://maps.google.com/maps?file=api&v=2&key=YOUR_GOOGLE_KEY" type="text/javascript"></script>
<script src="jQuery.bMap.1.2.3.js" type="text/javascript"></script>
<style type="text/css">
<!--
	#map{ width:500px;height:500px;float:left }
	#sideBar{ width:200px;height:500px;text-align:center;background:#fff;float:right }
	#sideBar div{ padding:2px 0; cursor:pointer }
	#sideBar div:hover{ text-decoration:underline }
	#buttons{ clear:both;text-align:center }
	.bSideSelect{ background:#dadae3; } /* clicked items get this class */
-->
</style>
<script type="text/javascript">

$(document).ready(function(){ 
	$("#map").bMap({
		mapZoom: 11,
		mapCenter:[51.501690392607,-0.1263427734375],
		mapSidebar:"sideBar", //id of the div to use as the sidebar
		markers:{"data":[
			{
				"lat":51.49757618329838,"lng":-0.1746654510498047,"title":"Science Museum","body":"Exhibition Road, London SW7"
			},{
				"lat":51.47769451182406,"lng":-0.0009441375732421875,"title":"Royal Observatory Greenwich","body":"Blackheath Ave, Greenwich, London SE10"
			},{
				"lat":51.49624032118747,"lng":-0.10857582092285156,"title":"Imperial War Museum","body":"Lambeth, London, SE1"
			},{
				"lat":51.51792987720294,"lng":-0.1272869110107422,"title":"British Museum"					
			},{
				"lat":51.495625811469374,"lng":-0.17642498016357422,"title":"Natural History Museum","body":"Cromwell Road, London, SW7"					
			},{
				"lat":51.50177053585362,"lng":-0.12908935546875,"title":"Churchill Museum"					
			}
		]}
	});
});

</script>
<div style="width:700px;height:500px;margin:0 auto">
	<div id="map"></div>
	<div id="sideBar"></div>
</div>



Comments:

Nice work.
Michael Pehl - 4/20/2010 6:19:46 AM
Very nice work. Will be useful for my latest project :-)

Thanks
Help with co-ordinates
Tasneem - 7/15/2010 3:03:08 PM
How do I go about inserting co-ordinates like these?

http://www.mapsofworld.com/lat_long/south-africa-lat-long.html

I'm having difficulty with this, because i want Cape Town, South Africa to be the centered point of the map.

Also will i be able to add a function where users can get directions from where they stay to a pointer on the map?

I'm not really good at coding, so having some difficulty thanks

Great plugin though!
Coords Reply
Darren - 7/16/2010 5:53:48 AM
Hi,

Glad you like the plugin. Interesting question. I was going to say, use the google page, with the google labs tool that shows the LatLng of the mouse position...... but the list on the site you sent is quite large for that.
An alternative would be to try to use the undocumented GLatLng.fromRadians(lat,lng,nofix) function mentioned here:
http://econym.org.uk/gmap/reference.htm
This is a good site for info about google maps!

There is also a page that can do the conversion here:
http://www.fcc.gov/mb/audio/bickel/DDDMMSS-decimal.html

But again , its a lot of work to manually convert everything!

You might want to copy the table into Excel, and use a formula to do the conversion...... by looking at the page source this appears to be the math:

form10.alat.value = Math.round(absdlat (absmlat/60.) (absslat/3600.) ) * latsign/1000000;
form10.alon.value = Math.round(absdlon (absmlon/60) (absslon/3600) ) * lonsign/1000000; latsign=1; lonsign=1;

I havnt tested anything, so I am not 100 sure the results will be accurate.

Darren
coords
Tasneem - 8/23/2010 10:46:48 PM
this is code i entered

$(document).ready(function () {
$("
coords
Tasneem - 8/23/2010 10:47:37 PM
this is code i entered

$(document).ready(function () {
$("
3rd attempt..
Tasneem - 8/23/2010 10:48:50 PM
mapCenter: [30.59482, 22.937506],
mapSidebar: "sideBar", //id of the div to use as the sidebar
markers: { "data": [
{
"lat": 33.35, "lng": 19.3, "title": "Science Museum", "body": "Exhibition Road, London SW7"
}, {
"lat": 33.371047, "lng": 19.307472, "title": "Royal Observatory Greenwich", "body": "Blackheath Ave, Greenwich, London SE10"
}
]

ignore the title of the markers, i didnt change them
Coords! aaah
Tasneem - 8/23/2010 10:59:38 PM
Sorry, been having trouble posting


Really can't get this co-ordinates right. Used that converter you gave me in the previous post.

If I use SouthAfrica/ Cape Town, South Africa and cities then my pointers in the middle of the sea far from the location I want it

I've used the converter but still having trouble :(
sorry
tasneem - 8/23/2010 11:10:18 PM
i am deeply sorry for all the posts. The site I've used for my co-ords was unreliable

Here is a nice site to find longitude and latitude
http://itouchmap.com/latlong.html

Anyways, Is there a way one can search for directions?
Coords
Darren - 8/24/2010 2:53:16 PM
Hi,
You cant post code on these pages. Perhaps put a link to the page in question that you are trying to make.

You can use the normal maps.google.com website to get the lat lng values. The google labs options at the top can add extra features including dropping pins on a map with lat lng values. You can also use an embed code to get them values.

As for the directions stuff. Its outside the scope of bMap but it has been done. The google code playground will show you how to use the directions features of google maps - and then you extend bMap. Because the map variable google use in their code playground is avalible in bMap as
$('#map').data('bMap').map
Trigger Markers Event
Kishan - 8/30/2010 5:22:03 AM
Hi Darren,
I have one question, How i can Trigger Google Map Markers by Out Side Elements like on click of any icon.
I need any java script function so that i can move this anywhere. Let me know if you have any suggestions related to this.
Markers
darren - 8/30/2010 11:44:50 AM
I fail to see how this question relates to bMap? Unless you are asking how the sidebar works? in which case, look at the code - or better still read the google API documentation.
Markers
Kishan - 8/30/2010 11:12:18 PM
Hi darren ,
Thanks for your suggestions, but my question is very simple, i just want to know in bMap Markers - How i can Trigger Markers by any outside element instead of using sidebar ? I am not able to find any javascript function for this.
Let me know if you require more details regarding same.Thanks in advance
Marker Code
Darren - 8/31/2010 3:51:33 AM
Hi,
Like I said, the code is free and open, so if you want to know how the sidebar imitates a click on a Marker, then its on the source. The method depends on the version of the maps API in qusetion, but in V2 the google function you need is:
GEvent.trigger()
The sidebar is created dynamically, so the exact implementation will depend on your setup.
Darren

 (*required)
 (*private)
 (*required)
 
© 2010 blocsoft.com All Rights Reserved. GPL License Privacy Policy Contact