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
V3 - Example 3V3 Example 5V3 Example 12
V3 API Custom Icons
Please note that unless stated, the examples shown here use the V2 of the google maps API - and bMap version 1.2.3
There are only three examples using the V3 API - and bMap 1.3

Advanced AJAX




How its done:

In this example we have used the full power of the AJAX functions. There are three variables you can set when using the AJAX functions. The first allows you to set the target URL of the AJAX request. To make it easy for you to process your data, and build the JSON response, there are two ways to pass data to the server. You can use the action variable, this takes a single string. Or if you need to send lots of information you can use the vars variable. Vars is passed to the function as an array, and is delivered server-side as an array too. These values are POSTed to the AJAX page.

This example also shows how to change the loading message to an animated GIF, and use satellite images on the map.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="http://maps.google.com/maps?file=api&v=2&key=YOUR_GOOGLE_KEY" type="text/javascript"></script>
<script type="text/javascript" src="jQuery.bMap.1.2.3.js"></script>
<style type="text/css">
<!--
	#map{ width:500px;height:500px;float:left }
	#layerBar{ width:200px;height:500px;text-align:center;background:#fff;float:right }
	#layerBar div{ padding:2px 0; cursor:pointer }
	#layerBar div:hover{ text-decoration:underline }
	#buttons{ clear:both;text-align:center }
	.bLyrHide{ color:#ddd; }
	.bMapLoadMsg{ position:relative; display:none; 
		background:#fff;opacity:0.8;width:70px;padding:10px;text-align:center;border:2px solid #000;
	}
-->
</style>
<script type="text/javascript">
	$(document).ready(function(){ 
		$("#map").bMap({
			//Here an image is used as the loading prompt...
			loadMsg:"<img src='loading.gif' alt='Loading...' width='64' height='64'>",
			mapZoom: 15,
			mapCenter: [51.31714872961282,-1.0788917541503906],
			//Here the map type is set...
			mapType: G_HYBRID_MAP,
			mapLayerbar:"layerBar"
		});
		$('#map').data('bMap').AJAXPolygon({	
			//AJAX service page
			serviceURL: 'AJAXservice.asp',
			//set the action POST var for field edges
			action: "bounds",
			//These values will be POSTed to the AJAX page as an array called 'vars' that can be used with a database ect
			vars: ['1', 'Field 1','#ff0']
		});
		$('#map').data('bMap').AJAXMarkers({	
			serviceURL: 'AJAXservice.asp',
			action: "Markers",			
			vars: ['FieldID', '1', 'Points 1']
		});
		$('#map').data('bMap').AJAXLine({	
			serviceURL: 'AJAXservice.asp',
			action: "bounds",
			vars: ['2', 'Field 2','#f0f']
		});
		$('#map').data('bMap').AJAXMarkers({ 
			serviceURL: 'AJAXservice.asp', 
			action: "Markers",
			vars: ['FieldID', '2', 'Points 2']
		});		
	});	
	//this button loads the third field
	function button1(){
		$('#map').data('bMap').AJAXMarkers({ 
			serviceURL: 'AJAXservice.asp',
			action: "Markers",
			vars: ['FieldID', '3', 'Points 3']
		});
		$('#map').data('bMap').AJAXPolygon({	
			serviceURL: 'AJAXservice.asp',
			action: "bounds",
			vars: ['3', 'Field 3','#0ff']
		});
	}
</script>
<div style="width:700px;height:500px;margin:0 auto">
	<div id="map"></div>
	<div id="layerBar"></div>
	<div id="buttons"> //this button loads the third field
		<input value="Load Field 3" type="button" onclick="button1();$(this).attr('disabled', true);">
	</div>
</div>



Comments:

Layer visibility on load
Mark - 8/26/2010 1:18:31 PM
I've been playing with example 7 using the new bMap 1.3 release and it works great! For my application I've eliminated fields 1, 2, 3, and I've kept points 1 and 2. Is it possible for the layer to load in a hidden state while keeping the layer bar text so users can show the specific layers they want to see? I did see you can set layer visible:"false" but it eliminates the layer bar text.
Layer Visibility
Darren - 8/27/2010 7:11:15 AM
Hi,
There is an undocumented feature that allows you to overide the options passed to the insertmarkers function when doing an AJAX request. You can try setting the visibility there. If that dont work, send me a link to your page so i can recreate the bug and implement a fix.
$("#map").data("bMap").AJAXMarkers({ serviceURL:'AJAX.php', action:'Markers', options:{visible:"false"} });
[ASK] PHP Code
Riky - 10/24/2010 8:27:07 PM
Can I get the PHP code for this example? so i can try this example in my local, you can send the code by email, master... please, help me.. thanks . sorry for my poor english
PHP Code
Darren - 10/25/2010 3:06:56 AM
Hi,
Yesterday someone pointed out that the bMap AJAXMarkers function as using GET not POST. It seems a temporary change to the code for testing around version 1.2.1 became permenant as the examples use REQUEST not POST to read the variables server-side. In the process I also (re)discovered a potential pitfal in the code when passing an array to PHP serverside. I am working on a solution and when I release the next versions of bMap I will create some new examples, with code samples. I use the twitter feed to alert new updates.

Darren
For bMap v1.3 en header
Mittaus - 12/7/2010 9:12:27 AM



Google Maps JavaScript API v3 Example: Common Loader

script type="text/javascript"src="http://maps.google.com/maps/api/js?v=3

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