I am using gmaps.js plugin http://hpneo.github.com/gmaps/
The Sliding Zoom Control and the InfoWindow don't show up and have some issues when they display. Link: http://bakasura.in/startupsradar/index.html
// JavaScript Document
$(document).ready(function () {
var map = new GMaps({
div: '#map',
lat: 13.00487,
lng: 77.576729,
zoom: 13,
});
GMaps.geolocate({
success: function (position) {
map.setCenter(position.coords.latitude, position.coords.longitude);
},
error: function (error) {
alert('Geolocation failed: ' + error.message);
},
not_supported: function () {
alert("Your browser does not support geolocation");
},
always: function () {
//alert("Done!");
}
});
map.addControl({
position: 'top_right',
text: 'Geolocate',
style: {
margin: '5px',
padding: '1px 6px',
border: 'solid 1px #717B87',
background: '#fff'
},
events: {
click: function () {
GMaps.geolocate({
success: function (position) {
map.setCenter(position.coords.latitude, position.coords.longitude);
},
error: function (error) {
alert('Geolocation failed: ' + error.message);
},
not_supported: function () {
alert("Your browser does not support geolocation");
}
});
}
}
});
map.addMarker({
lat: 13.00487,
lng: 77.576729,
title: 'Lima',
icon: "http://i.imgur.com/3YJ8z.png",
infoWindow: {
content: '<p>HTML Content</p>'
}
});
});
Bootstrap was conflicting with the rendering of Maps
Adding these lines of CSS did the trick
/* Bootstrap Css Map Fix*/
#mainBody #map img {
max-width: none;
}
/* Bootstrap Css Map Fix*/
#mainBody #map label {
width: auto; display:inline;
}
I had this before, it was some of my own CSS that overwrote some of the values in maps. I would suggest checking all styles applied to img tags. Especially width values that is set to images globally.
Related
My objective right now is to basically add a marker wherever the user is in the google maps. The API works, a KML file I added with polygons work and i'm sure it doesn't mess with any of the code so far.
However, I have" Cannot read property 'setPosition' of undefined" error at line 99 of the code. it will probably have an easy solution but I cannot see it myself.
<!DOCTYPE html>
<html>
<head>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAjp8cvAcEYCwzuCyTQORL3Z1iQPdQMg_8&callback=initMap" async defer>
</script>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<title>Protoype: Just Don't</title>
<meta charset="utf-8">
<style>
html, body, #map {
height: 100%;
margin: 0;
padding: 0;
}
/* Style the buttons so that they are consistently coloured and sized */
.button {
background-color: #008CBA; /* Blue */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
}
/* Style the search box */
.search input[type=text] {
float: right;
padding: 6px;
border: none;
margin-top: 8px;
margin-right: 16px;
font-size: 17px;
}
/* When the screen is less than 640px wide, stack the search field vertically instead of horizontally */
#media screen and (max-width: 640px) {
.search a, .search input[type=text] {
float: none;
display: block;
text-align: left;
width: 100%;
margin: 0;
padding: 14px;
}
.search input[type=text] {
border: 1px solid #ccc;
}
}
</style>
</head>
<body>
<h3>Just don't app test</h3>
<div class="search">
<input type=text placeholder="Search..">
</div>
Settings
Account
Add Review
<div id="map"></div>
<script>
var map, infoWindow;
function initMap() {
InfoWindow = new google.maps.InfoWindow;
var Paisley = {lat: 55.845890, lng: -4.423741};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 17,
center: Paisley
});
var kmlLayer = new google.maps.KmlLayer({
url: 'https://firebasestorage.googleapis.com/v0/b/just-don-t.appspot.com/o/Project%20examples.kml?alt=media&token=65140cfc-de3a-4658-8b2b-0354f4909d38',
suppressInfoWindows: true,
map: map
});
kmlLayer.addListener('click', function(kmlEvent) {
var text = kmlEvent.featureData.description;
showInContentWindow(text);
});
function showInContentWindow(text) {
var sidediv = document.getElementById('content-window');
sidediv.innerHTML = text;
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
;
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
infoWindow.setPosition (pos);
infoWindow.setContent('Location found.');
infoWindow.open(map);
map.setCenter(pos);
}, function() {
handleLocationError(true, infoWindow, map.getCenter());
});
} else {
// Browser doesn't support Geolocation
handleLocationError(false, infoWindow, map.getCenter());
}
}
function handleLocationError(browserHasGeolocation, infoWindow, pos) {
infoWindow.setPosition(pos);
infoWindow.setContent(browserHasGeolocation ?
'Error: The Geolocation service failed.' :
'Error: Your browser doesn\'t support geolocation.');
infoWindow.open(map);
}
</script>
</body>
Any tips on how to solve it or if you find another problem in my code will be greatly appreciated.
The main issue I believe was the mismatch in variable names. Initially you declared InfoWindow when creating the reference but throughout thereafter refer to infoWindow. Additionally the functions showInContentWindow and handleLocationError needn't be declared within the initMap function.
The following works OK - but the geoLocation puts the Location found nowhere near Paisley for me ... the css here was just basic for testing.
Anyone would think Paisley was an unsafe place after dark judging by some of the descriptions that appear when clicking on the KML Layer - never saw much of Paisley when we used to go to 'Club69' back in the day...
<html>
<head>
<meta charset='utf-8' />
<title>Google Maps: KML Layer</title>
<script id='gm' async defer src="//maps.google.com/maps/api/js?key=AIzaSyAjp8cvAcEYCwzuCyTQORL3Z1iQPdQMg_8&callback=initMap®ion=en-GB&language=en"></script>
<script>
var infowindow, map, Paisley, kmlLayer;
var text, pos
function initMap(){
infowindow = new google.maps.InfoWindow;
Paisley = { lat: 55.845890, lng: -4.423741 };
map = new google.maps.Map( document.getElementById('map'), {
zoom: 17,
center: Paisley
});
kmlLayer = new google.maps.KmlLayer({
url: 'https://firebasestorage.googleapis.com/v0/b/just-don-t.appspot.com/o/Project%20examples.kml?alt=media&token=65140cfc-de3a-4658-8b2b-0354f4909d38',
suppressInfoWindows: true,
map: map
});
kmlLayer.addListener( 'click', function( event ) {
text = event.featureData.description;
showInContentWindow( text );
});
if( navigator.geolocation ) {
navigator.geolocation.getCurrentPosition( function( position ) {
pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
infowindow.setPosition( pos );
infowindow.setContent( 'Location found.' );
infowindow.open( map );
map.setCenter( pos );
console.info( 'Location found: %s, %s', pos.lat, pos.lng );
}, function() {
handleLocationError( true, infowindow, map.getCenter() );
});
} else {
handleLocationError( false, infowindow, map.getCenter() );
}
}
function showInContentWindow( text ) {
document.getElementById('content-window').innerHTML = text;
}
function handleLocationError( browserHasGeolocation, infowindow, pos ) {
infowindow.setPosition( pos );
infowindow.setContent( browserHasGeolocation ? 'Error: The Geolocation service failed.' : 'Error: Your browser doesn\'t support geolocation.');
infowindow.open( map );
}
</script>
<style>
body{ background:white; }
#container{
width: 90%;
min-height: 90vh;
height:auto;
box-sizing:border-box;
margin: auto;
float:none;
margin:1rem auto;
background:whitesmoke;
padding:1rem;
border:1px solid gray;
display:block;
}
#map {
width: 100%;
height: 100%;
clear:none;
display:block;
z-index:1!important;
background:white;
}
</style>
</head>
<body>
<div id='container'>
<div id='map'></div>
<div id='content-window'></div>
</div>
</body>
</html>
I'm wondering how can I use the new official Google Maps map marker, in my web-application with Google Maps API v3 (JavaScript).
This is the picture. I like it.
By the way, is there a way to change its color?
Thanks and happy x-mas :-)
You can not add the google maps' marker. You can only use the default marker or custom your marker.
This is an example of default marker:
function initMap() {
var myLatLng = {lat: -25.363, lng: 131.044};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: myLatLng
});
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: 'Hello World!'
});
}
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
<div id="map"></div>
<script async defer
src="https://maps.googleapis.com/maps/api/js?callback=initMap">
</script>
And this is an example of custom marker:
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
zoom: 16,
center: new google.maps.LatLng(-33.91722, 151.23064),
mapTypeId: 'roadmap'
});
var iconBase = 'https://maps.google.com/mapfiles/kml/shapes/';
var icons = {
parking: {
icon: iconBase + 'parking_lot_maps.png'
},
library: {
icon: iconBase + 'library_maps.png'
},
info: {
icon: iconBase + 'info-i_maps.png'
}
};
var features = [
{
position: new google.maps.LatLng(-33.91721, 151.22630),
type: 'info'
}, {
position: new google.maps.LatLng(-33.91539, 151.22820),
type: 'info'
}, {
position: new google.maps.LatLng(-33.91747, 151.22912),
type: 'info'
}, {
position: new google.maps.LatLng(-33.91910, 151.22907),
type: 'info'
}, {
position: new google.maps.LatLng(-33.91725, 151.23011),
type: 'info'
}, {
position: new google.maps.LatLng(-33.91872, 151.23089),
type: 'info'
}, {
position: new google.maps.LatLng(-33.91784, 151.23094),
type: 'info'
}, {
position: new google.maps.LatLng(-33.91682, 151.23149),
type: 'info'
}, {
position: new google.maps.LatLng(-33.91790, 151.23463),
type: 'info'
}, {
position: new google.maps.LatLng(-33.91666, 151.23468),
type: 'info'
}, {
position: new google.maps.LatLng(-33.916988, 151.233640),
type: 'info'
}, {
position: new google.maps.LatLng(-33.91662347903106, 151.22879464019775),
type: 'parking'
}, {
position: new google.maps.LatLng(-33.916365282092855, 151.22937399734496),
type: 'parking'
}, {
position: new google.maps.LatLng(-33.91665018901448, 151.2282474695587),
type: 'parking'
}, {
position: new google.maps.LatLng(-33.919543720969806, 151.23112279762267),
type: 'parking'
}, {
position: new google.maps.LatLng(-33.91608037421864, 151.23288232673644),
type: 'parking'
}, {
position: new google.maps.LatLng(-33.91851096391805, 151.2344058214569),
type: 'parking'
}, {
position: new google.maps.LatLng(-33.91818154739766, 151.2346203981781),
type: 'parking'
}, {
position: new google.maps.LatLng(-33.91727341958453, 151.23348314155578),
type: 'library'
}
];
// Create markers.
features.forEach(function(feature) {
var marker = new google.maps.Marker({
position: feature.position,
icon: icons[feature.type].icon,
map: map
});
});
}
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
<div id="map"></div>
<script async defer
src="https://maps.googleapis.com/maps/api/js?callback=initMap">
</script>
Tell me if you have some questions.
So I have found a couple of ways to get maps onto my page, the first version is by using an iframe like so:
<iframe src="https://www.google.com/maps/embed/v1/place?key=[APIKEY]&q=place_id:[PlaceID]"></iframe>
which gives a marker like the following image with the name of the place next to the marker:
However, this isn't perfect as it has that massive white box in the top left and according to many SO posts, you are unable to remove it.
So I thought I would try the js route so have the following code:
var map = new google.maps.Map(this, {
zoom: 15,
center: { lat: options.latitude, lng: options.longitude }
});
marker = new google.maps.Marker({
map: map,
title: options.title
});
marker.setPlace({
placeId: options.placeId,
location: { lat: options.latitude, lng: options.longitude }
});
var infowindow = new google.maps.InfoWindow(
{
content: '<strong>' + options.title + '</strong><br />' + options.address
});
google.maps.event.addListener(marker, 'click', function () {
infowindow.open(map, marker);
});
Where all the options are filled in with proper values. However, this produces the following map which is better as it doesn't have the white box:
However, the second map doesn't have the shop text on the map even though it is using the same place id as the first one is.
Is there any way to change the js code so that it will include the place text like in the iframe version? I have searched all the documentation and examples but couldn't find any setting to do this
You can add that label to the map yourself. One option is to use an InfoBox:
function addMapLabel(text, latlng, map) {
var labelText = "<b>" + text + "</b>";
var myOptions = {
content: labelText,
boxStyle: {
border: "none",
textAlign: "center",
fontSize: "8pt",
width: "auto",
color: "#800000"
},
disableAutoPan: true,
pixelOffset: new google.maps.Size(10, -10),
position: latlng,
closeBoxURL: "",
isHidden: false,
pane: "mapPane",
enableEventPropagation: true
};
var ibLabel = new InfoBox(myOptions);
ibLabel.open(map);
}
proof of concept fiddle
code snippet:
function addMapLabel(text, latlng, map) {
var labelText = "<b>" + text + "</b>";
var myOptions = {
content: labelText,
boxStyle: {
border: "none",
textAlign: "center",
fontSize: "8pt",
width: "auto",
color: "#800000"
},
disableAutoPan: true,
pixelOffset: new google.maps.Size(10, -10),
position: latlng,
closeBoxURL: "",
isHidden: false,
pane: "mapPane",
enableEventPropagation: true
};
var ibLabel = new InfoBox(myOptions);
ibLabel.open(map);
}
var map;
var options = {
placeId: "ChIJ68TmaaTCe0gRy70pZDzQ17U",
latitude: 53.7153659,
longitude: -1.8790866,
title: "Dickies Tiles",
address: "Aachen Way, Halifax HX1 3ND, United Kingdom"
}
function initialize() {
var map = new google.maps.Map(document.getElementById("map_canvas"), {
zoom: 15,
center: {
lat: options.latitude,
lng: options.longitude
}
});
marker = new google.maps.Marker({
map: map,
title: options.title
});
marker.setPlace({
placeId: options.placeId,
location: {
lat: options.latitude,
lng: options.longitude
}
});
var infowindow = new google.maps.InfoWindow({
content: '<strong>' + options.title + '</strong><br />' + options.address
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
addMapLabel(options.title, new google.maps.LatLng(options.latitude, options.longitude), map);
}
google.maps.event.addDomListener(window, "load", initialize);
html,
body,
#map_canvas {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script src="https://cdn.rawgit.com/googlemaps/v3-utility-library/master/infobox/src/infobox.js"></script>
<div id="map_canvas"></div>
Just in case anyone else needs this type of thing, I found a better plugin than the infobox one in my accepted answer (although I am leaving that as the accepted as it pointed me in the right direction). It is:
MarkerWithLabel.
It offers the same as InfoBox but also lets you click on the label, as you would the marker, to open the info window
An example of how I used it would be:
var map;
var options = {
placeId: "ChIJ68TmaaTCe0gRy70pZDzQ17U",
latitude: 53.7153659,
longitude: -1.8790866,
title: "Dickies Tiles",
address: "Aachen Way, Halifax HX1 3ND, United Kingdom"
}
function initialize() {
var map = new google.maps.Map(document.getElementById("map_canvas"), {
zoom: 15,
center: {
lat: options.latitude,
lng: options.longitude
}
});
var marker = new MarkerWithLabel({
position: new google.maps.LatLng(options.latitude, options.longitude),
map: map,
title: options.title,
labelContent: options.title,
labelAnchor: new google.maps.Point(-13, 15),
labelClass: "map-label",
labelStyle: {
border: 'none',
textAlign: 'center',
fontSize: '12px',
width: 'auto',
color: '#800000'
}
});
marker.setPlace({
placeId: options.placeId,
location: {
lat: options.latitude,
lng: options.longitude
}
});
var infowindow = new google.maps.InfoWindow({
content: '<strong>' + options.title + '</strong><br />' + options.address
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
}
google.maps.event.addDomListener(window, "load", initialize);
html,
body,
#map_canvas {
height: 100%;
width: 100%;
margin: 0px;
padding: 0px
}
.map-label { text-shadow: -1px -1px 0 #ffffff,1px -1px 0 #ffffff,-1px 1px 0 #ffffff,1px 1px 0 #ffffff; font-weight:bold; }
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script src="https://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerwithlabel/src/markerwithlabel.js"></script>
<div id="map_canvas"></div>
I've made a google maps API (HTML) script that created markers when the user clicks on the map. I've also integrated Google+ login functions so users are unique and have profiles. I now want to make it so users can create their markers on their desired positions and then save the map so they can come back to it later. I however don't want them to use this "https://developers.google.com/maps/documentation/javascript/examples/save-widget" provided function because then the markers are synched to their google+. In other words I only want the markers to save to my website, not to their personal google maps. How would I go about saving the state of the map only on my site?
Heres the fiddle of my code: https://jsfiddle.net/hgvsurt5/
Heres the code:
<head>
<style>
#map-canvas {
width: 900px;
height: 600px;
}
.controls {
margin-top: 16px;
border: 1px solid transparent;
border-radius: 2px 0 0 2px;
box-sizing: border-box;
-moz-box-sizing: border-box;
height: 32px;
outline: none;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
#pac-input {
background-color: #fff;
font-family: Roboto;
font-size: 15px;
font-weight: 300;
margin-left: 12px;
padding: 0 11px 0 13px;
text-overflow: ellipsis;
width: 400px;
}
#pac-input:focus {
border-color: #4d90fe;
}
.pac-container {
font-family: Roboto;
}
#type-selector {
color: #fff;
background-color: #4d90fe;
padding: 5px 11px 0px 11px;
}
#type-selector label {
font-family: Roboto;
font-size: 13px;
font-weight: 300;
}
</style>
<title>Places search box</title>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&libraries=places"></script>
<script>
// This example adds a search box to a map, using the Google Place Autocomplete
// feature. People can enter geographical searches. The search box will return a
// pick list containing a mix of places and predicted search terms.
function initialize() {
var marker = []
var map = new google.maps.Map(document.getElementById('map-canvas'), {
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var defaultBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(-33.8902, 151.1759),
new google.maps.LatLng(-33.8474, 151.2631));
map.fitBounds(defaultBounds);
// Create the search box and link it to the UI element.
var input = /** #type {HTMLInputElement} */
(
document.getElementById('pac-input'));
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
var searchBox = new google.maps.places.SearchBox(
/** #type {HTMLInputElement} */
(input));
// [START region_getplaces]
// Listen for the event fired when the user selects an item from the
// pick list. Retrieve the matching places for that item.
google.maps.event.addListener(searchBox, 'places_changed', function() {
var places = searchBox.getPlaces();
if (places.length == 0) {
return;
}
</script>
<script>
var map;
var myCenter = new google.maps.LatLng(51.508742, -0.120850);
function initialize() {
var mapProp = {
center: myCenter,
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
google.maps.event.addListener(map, 'click', function(event) {
placeMarker(event.latLng);
});
}
function placeMarker(location) {
var marker = new google.maps.Marker({
position: location,
map: map,
draggable: true,
});
var infowindow = new google.maps.InfoWindow({
content: 'Latitude: ' + location.lat() + '<br>Longitude: ' + location.lng()
});
infowindow.open(map, marker);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="googleMap" style="width:900px;height:600px;"></div>
</body>
You must somehow bring the desired data into a format which may be sended and stored. A good approach would be to use a Data-layer to draw the features on the map, you may easily use the method toGeoJson of the Data-layer to convert the data into a geoJson and send it to a server(where you store the data).
A simple implementation:
function initialize() {
var map = new google.maps.Map(document.getElementById("googleMap"), {
center: new google.maps.LatLng(51.508742, -0.120850),
zoom: 5,
noClear: true
}),
//this may be the stored data
data = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [-0.120850, 51.508742]
},
"properties": {}
}]
},
win = new google.maps.InfoWindow,
//some buttons for interaction
ctrl = document.getElementById('datactrl'),
fx = {
'data-save': {
click: function() {
//use this method to store the data somewhere,
//e.g. send it to a server
map.data.toGeoJson(function(json) {
data = json;
});
}
},
'data-show': {
click: function() {
alert('you may send this JSON-string to a server and store it there:\n\n' +
JSON.stringify(data))
}
},
'data-load': {
click: function() {
//use this method to load the data from somwhere
//e.g. from a server via loadGeoJson
map.data.forEach(function(f) {
map.data.remove(f);
});
map.data.addGeoJson(data)
},
init: true
},
'data-clear': {
click: function() {
//use this method to clear the data
//when you also want to remove the data on the server
//send a geoJSON with empty features-array to the server
map.data.forEach(function(f) {
map.data.remove(f);
});
data = {
type: "FeatureCollection",
features: []
};
}
}
};
for (var id in fx) {
var o = ctrl.querySelector('input[id=' + id + ']');
google.maps.event.addDomListener(o, 'click', fx[id].click);
if (fx[id].init) {
google.maps.event.trigger(o, 'click');
}
}
map.controls[google.maps.ControlPosition.TOP_CENTER].push(ctrl);
function placeMarker(location) {
var feature = new google.maps.Data.Feature({
geometry: location
});
map.data.add(feature);
}
google.maps.event.addListener(map, 'click', function(event) {
placeMarker(event.latLng);
});
google.maps.event.addListener(map.data, 'click', function(e) {
if (e.feature.getGeometry().getType() === 'Point') {
win.setOptions({
content: 'Latitude: ' + e.feature.getGeometry().get().lat() +
'<br>Longitude: ' + e.feature.getGeometry().get().lng(),
pixelOffset: new google.maps.Size(0, -40),
map: map,
position: e.feature.getGeometry().get()
});
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
html,
body,
#googleMap {
height: 100%;
margin: 0;
padding: 0;
}
<script src="https://maps.googleapis.com/maps/api/js?v=3"></script>
<div id="googleMap">
<div id="datactrl">
<input type="button" id="data-save" value="save" />
<input type="button" id="data-show" value="show saved data" />
<input type="button" id="data-load" value="load saved data" />
<input type="button" id="data-clear" value="remove all data" />
</div>
</div>
I've made it work by these codes for an addtional title (a new div inside fancybox):
beforeShow: function(){
this.title=$(this.element).data('caption');
this.title2="<div class='photo_exif'>"+$(this.element).data('exif')+"</div>";
$(this.title2)
.bind("contextmenu", function (e) {
return false; /* Disables right click */
})
.prependTo( $.fancybox.inner );
}
and the html is :
<a href='PhotoURL' class='fancybox' data-fancybox-group='gallery' data-caption='PhotoTitle' data-exif='photoTitle2'>pic</a>
now i want this div (div.photo_exif) hover to show or hide, so i added these codes:
afterShow:function() {
$("#fancybox-wrap").hover(function() {
$(".photo_exif").show();
}, function() {
$(".photo_exif").hide();
});
}
but it doesnt work. The div is always show on fancybox. My css is :
.photo_exif {
position: absolute;
bottom: 0;
left: 0;
color: #fff;
width:100%;
height:30px;
background: #000;
background: rgba(0, 0, 0, .8);
}
and my whole fancybox code (with ie6 crack) is :
$('.fancybox').fancybox({
fitToView: false,
mouseWheel: false,
beforeShow: function(){
this.title=$(this.element).data('caption');
this.title2="<div class='photo_exif'>"+$(this.element).data('exif')+"</div>";
$(this.title2)
.bind("contextmenu", function (e) {
return false; /* Disables right click */
})
.prependTo( $.fancybox.inner );
},
afterShow: function(){
if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) <= 6) {
$("div#fancybox-buttons").css("top", $("html").scrollTop());
$(window).scroll(function () {
$("div#fancybox-buttons").css("top", $("html").scrollTop());
});
}
$("#fancybox-wrap").hover(function() {
$(".photo_exif").show();
}, function() {
$(".photo_exif").hide();
});
}
});
Is there anything wrong?
This one was easy. This line of your code :
$("#fancybox-wrap").hover(function() {
... should be :
$(".fancybox-wrap").hover(function() {
The fancybox selector is a class not an ID