This plugin makes it easy to put multiple markers on Map using Google Map API V3.
Map Marker is very useful when you have a list of data & you want to show all of them on Map too.
Like most of the jQuery plugins, this plugin is very straight forward to setup.
It has some nice options & uses JSON formatted data for every Locations.
Also make note that you must have to pass the Location values using Lattitude & Longitude co-ordinates of the that Location (due to Google map API limitation).
Below steps will make more sense of using this plugin.
Step-1 : Include necessary JS files in your <head> tag
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script type="text/javascript" src="js/mapmarker.jquery.js"></script>
Step-2 : Create a Map container using div tag & give it an ID in your html body
<div id="map" style="width: 550px; height: 450px; border:2px solid red;"></div>
Step-3 : Apply the Plugin to the Map element using below code. Put the code before closing </head> tag
<script type="text/javascript">
$(document).ready(function(){
//set up markers
var myMarkers = {"markers": [
{"latitude": "31.42866311735861", "longitude":"-98.61328125", "icon": "img/house.png", "baloon_text": "This is <strong>Texas</strong>"},
{"latitude": "35.101934057246055", "longitude":"-96.6796875", "icon": "img/castle.png", "baloon_text": "This is <strong>Oklahoma</strong>"},
{"latitude": "38.61687046392973", "longitude":"-98.876953125", "icon": "img/house.png", "baloon_text": "This is <strong>Kansas</strong>"}
]
};
//set up map options
$("#map").mapmarker({
zoom : 5,
center : 'United States',
markers : myMarkers
});
});
</script>
myMarker : We have used this variable to store JSON data of each locations. Each locations will include 4 entities.
1. latitude – latitude of the location
2. longitude – longitude of the location
3. icon – a custom icon to display on map as marker (16 x 16 pixels size)
4. baloon_text – a Text to display in a Baloon on map when clicked on that specific Marker. You can also use this text in HTML format.
Use below link if you want to get latitude & longitude
http://www.findlatitudeandlongitude.com/find-address-from-latitude-and-longitude.php
Additionally, there are 2 more options which you can set on Map.
1. zoom – to set default zoom level of the Map. Increase the value to zoom-in & Decrease the value to zoom-out
2. center – to specify the center location of the Map. Make sure the center location address you enter is spelled properly.
3. markers – this will be simply the Markers variable we created, here it is “myMarkers”
Step-4 : That’s All
I have tested the plugin on Windows with Chrome, FF 3.6, IE 6, IE 8, Safari 4.
If you find any issue, please post a comment on it & I will make the corrections.
You can simply put your photo gallery URL inside the Baloon on marker.
yes inside that u can add html format code. ur welcome
great.
How i can assign a photogalery for each marker?? I would like click on the marker and open a gallery like prettygallery o fancy.. it’s possibile?
andry
“baloon_text”: “This is Kansas”
inside?… i will try.. ty
andry
Hi i was wonder if this plugin has the capability to have categories or different icons for different locations, my company uses maps mostly for parks and recreation districts. So i one map you would have Skateparks, pools, gyms, etc.
yes u can add different icons, just set the “icon” property to the path of icon image in you json records
is it possible to center the map on the available markers (center and zoom to fit all markers in the available area?)
and additionally html inside the popup is possible, but is it also possible to restyle the popup itself? round corners, no round corners, different close button, border, …
You can specify the Center location in the options like below,
center : ‘United States’
I will look for infoWindow (popup) styling & see what we can do about that. It would be a good upgrade to the plugin
How do I get rid of the padding/spacing around the map itself. I would like the map to rest nicely against the border of the browser itself.
I tried margin: 0 and float: left in the actualy DIV of the map but nothing seems to work. Is this a limitation to using their new API or this JS?
nm, I just put the margin: 0; on the body tag and all is good!!
hmm. what u need is just reset css. have a look at below link
http://meyerweb.com/eric/tools/css/reset/
Hm. How to spread out markers?
If several markers has same city they go all on top of each other?
Just increase the zoom settings & it will show the markers separately.
No, zoom settings dont work in this case. Maybe I’ll explain a bit badly.
I’ll add exactly the same coordinates for 10 markers in same city. So markers with same coordinates lays on top of each other.
Is there a way to spread each marker a bit? Since I dont have the street name, I can only give city. And I do only want to add city.
until u don’t give some difference in addresses, they will be seen overlapped only.
Can you change the pop out balloon size with this? or is that something done with the API
The pop out baloon size is dependent on the size of the content inside it. So if you put a div element with the width of 400px, the baloon width will increase to 400px+some paddings over it.