How to get an image from the database and show that image in google map info window











up vote
-1
down vote

favorite












I am trying to get an image from the database and show it in the google map info window. i have two elements which is Description and Image.
Description in the database is showing in the google map info window without an error. but Image won't be appeared. here is my code



<?php
include_once 'header.php';
include 'locations_model.php';
?>
<div id="map"></div>
<script>
var map;
var marker;
var infowindow;
var red_icon = 'http://maps.google.com/mapfiles/ms/icons/red-dot.png' ;
var purple_icon = 'http://maps.google.com/mapfiles/ms/icons/purple-dot.png' ;
var locations = <?php get_all_locations() ?>;

function initMap() {
var france = {lat: 6.8602, lng: 80.0535};
infowindow = new google.maps.InfoWindow();
map = new google.maps.Map(document.getElementById('map'), {
center: france,
zoom: 8
});


var i ; var confirmed = 0;
for (i = 0; i < locations.length; i++) {

marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,
icon : locations[i][4] === '1' ? red_icon : purple_icon,
html: document.getElementById('form')
});

google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
confirmed = locations[i][4] === '1' ? 'checked' : 0;
$("#confirmed").prop(confirmed,locations[i][4]);
$("#id").val(locations[i][0]);
$("#description").val(locations[i][3]);
$("#image").val(locations[i][5]);
$("#form").show();
infowindow.setContent(marker.html);
infowindow.open(map, marker);
}
})(marker, i));
}
}

function saveData() {
var confirmed = document.getElementById('confirmed').checked ? 1 : 0;
var id = document.getElementById('id').value;
var url = 'locations_model.php?confirm_location&id=' + id + '&confirmed=' + confirmed;
downloadUrl(url, function(data, responseCode) {
if (responseCode === 200 && data.length > 1) {
infowindow.close();
window.location.reload(true);
}else{
infowindow.setContent("<div style='color: purple; font-size: 25px;'>Inserting Errors</div>");
}
});
}


function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;

request.onreadystatechange = function() {
if (request.readyState == 4) {
callback(request.responseText, request.status);
}
};

request.open('GET', url, true);
request.send(null);
}




<div style="display: none" id="form">
<table class="map1">
<tr>
<input name="id" type='hidden' id='id'/>
<td><a>Description:</a></td>
<td><textarea disabled id='description' placeholder='Description'></textarea></td>
</tr>

<tr>

<td><a>Image:</a></td>
<td><input type="image" disabled id='image' alt="" /></td>
</tr>
<tr>
<td><b>Confirm Location ?:</b></td>
<td><input id='confirmed' type='checkbox' name='confirmed'></td>
</tr>

<tr><td></td><td><input type='button' value='Save' onclick='saveData()'/></td></tr>
</table>







The image is getting by as an user input. the input image is successful recorded in the database. but it not visible in the info window










share|improve this question






















  • just as an aside, you realise your AJAX code will only ever work in Internet Explorer?
    – ADyson
    Nov 20 at 17:14















up vote
-1
down vote

favorite












I am trying to get an image from the database and show it in the google map info window. i have two elements which is Description and Image.
Description in the database is showing in the google map info window without an error. but Image won't be appeared. here is my code



<?php
include_once 'header.php';
include 'locations_model.php';
?>
<div id="map"></div>
<script>
var map;
var marker;
var infowindow;
var red_icon = 'http://maps.google.com/mapfiles/ms/icons/red-dot.png' ;
var purple_icon = 'http://maps.google.com/mapfiles/ms/icons/purple-dot.png' ;
var locations = <?php get_all_locations() ?>;

function initMap() {
var france = {lat: 6.8602, lng: 80.0535};
infowindow = new google.maps.InfoWindow();
map = new google.maps.Map(document.getElementById('map'), {
center: france,
zoom: 8
});


var i ; var confirmed = 0;
for (i = 0; i < locations.length; i++) {

marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,
icon : locations[i][4] === '1' ? red_icon : purple_icon,
html: document.getElementById('form')
});

google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
confirmed = locations[i][4] === '1' ? 'checked' : 0;
$("#confirmed").prop(confirmed,locations[i][4]);
$("#id").val(locations[i][0]);
$("#description").val(locations[i][3]);
$("#image").val(locations[i][5]);
$("#form").show();
infowindow.setContent(marker.html);
infowindow.open(map, marker);
}
})(marker, i));
}
}

function saveData() {
var confirmed = document.getElementById('confirmed').checked ? 1 : 0;
var id = document.getElementById('id').value;
var url = 'locations_model.php?confirm_location&id=' + id + '&confirmed=' + confirmed;
downloadUrl(url, function(data, responseCode) {
if (responseCode === 200 && data.length > 1) {
infowindow.close();
window.location.reload(true);
}else{
infowindow.setContent("<div style='color: purple; font-size: 25px;'>Inserting Errors</div>");
}
});
}


function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;

request.onreadystatechange = function() {
if (request.readyState == 4) {
callback(request.responseText, request.status);
}
};

request.open('GET', url, true);
request.send(null);
}




<div style="display: none" id="form">
<table class="map1">
<tr>
<input name="id" type='hidden' id='id'/>
<td><a>Description:</a></td>
<td><textarea disabled id='description' placeholder='Description'></textarea></td>
</tr>

<tr>

<td><a>Image:</a></td>
<td><input type="image" disabled id='image' alt="" /></td>
</tr>
<tr>
<td><b>Confirm Location ?:</b></td>
<td><input id='confirmed' type='checkbox' name='confirmed'></td>
</tr>

<tr><td></td><td><input type='button' value='Save' onclick='saveData()'/></td></tr>
</table>







The image is getting by as an user input. the input image is successful recorded in the database. but it not visible in the info window










share|improve this question






















  • just as an aside, you realise your AJAX code will only ever work in Internet Explorer?
    – ADyson
    Nov 20 at 17:14













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I am trying to get an image from the database and show it in the google map info window. i have two elements which is Description and Image.
Description in the database is showing in the google map info window without an error. but Image won't be appeared. here is my code



<?php
include_once 'header.php';
include 'locations_model.php';
?>
<div id="map"></div>
<script>
var map;
var marker;
var infowindow;
var red_icon = 'http://maps.google.com/mapfiles/ms/icons/red-dot.png' ;
var purple_icon = 'http://maps.google.com/mapfiles/ms/icons/purple-dot.png' ;
var locations = <?php get_all_locations() ?>;

function initMap() {
var france = {lat: 6.8602, lng: 80.0535};
infowindow = new google.maps.InfoWindow();
map = new google.maps.Map(document.getElementById('map'), {
center: france,
zoom: 8
});


var i ; var confirmed = 0;
for (i = 0; i < locations.length; i++) {

marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,
icon : locations[i][4] === '1' ? red_icon : purple_icon,
html: document.getElementById('form')
});

google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
confirmed = locations[i][4] === '1' ? 'checked' : 0;
$("#confirmed").prop(confirmed,locations[i][4]);
$("#id").val(locations[i][0]);
$("#description").val(locations[i][3]);
$("#image").val(locations[i][5]);
$("#form").show();
infowindow.setContent(marker.html);
infowindow.open(map, marker);
}
})(marker, i));
}
}

function saveData() {
var confirmed = document.getElementById('confirmed').checked ? 1 : 0;
var id = document.getElementById('id').value;
var url = 'locations_model.php?confirm_location&id=' + id + '&confirmed=' + confirmed;
downloadUrl(url, function(data, responseCode) {
if (responseCode === 200 && data.length > 1) {
infowindow.close();
window.location.reload(true);
}else{
infowindow.setContent("<div style='color: purple; font-size: 25px;'>Inserting Errors</div>");
}
});
}


function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;

request.onreadystatechange = function() {
if (request.readyState == 4) {
callback(request.responseText, request.status);
}
};

request.open('GET', url, true);
request.send(null);
}




<div style="display: none" id="form">
<table class="map1">
<tr>
<input name="id" type='hidden' id='id'/>
<td><a>Description:</a></td>
<td><textarea disabled id='description' placeholder='Description'></textarea></td>
</tr>

<tr>

<td><a>Image:</a></td>
<td><input type="image" disabled id='image' alt="" /></td>
</tr>
<tr>
<td><b>Confirm Location ?:</b></td>
<td><input id='confirmed' type='checkbox' name='confirmed'></td>
</tr>

<tr><td></td><td><input type='button' value='Save' onclick='saveData()'/></td></tr>
</table>







The image is getting by as an user input. the input image is successful recorded in the database. but it not visible in the info window










share|improve this question













I am trying to get an image from the database and show it in the google map info window. i have two elements which is Description and Image.
Description in the database is showing in the google map info window without an error. but Image won't be appeared. here is my code



<?php
include_once 'header.php';
include 'locations_model.php';
?>
<div id="map"></div>
<script>
var map;
var marker;
var infowindow;
var red_icon = 'http://maps.google.com/mapfiles/ms/icons/red-dot.png' ;
var purple_icon = 'http://maps.google.com/mapfiles/ms/icons/purple-dot.png' ;
var locations = <?php get_all_locations() ?>;

function initMap() {
var france = {lat: 6.8602, lng: 80.0535};
infowindow = new google.maps.InfoWindow();
map = new google.maps.Map(document.getElementById('map'), {
center: france,
zoom: 8
});


var i ; var confirmed = 0;
for (i = 0; i < locations.length; i++) {

marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map,
icon : locations[i][4] === '1' ? red_icon : purple_icon,
html: document.getElementById('form')
});

google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
confirmed = locations[i][4] === '1' ? 'checked' : 0;
$("#confirmed").prop(confirmed,locations[i][4]);
$("#id").val(locations[i][0]);
$("#description").val(locations[i][3]);
$("#image").val(locations[i][5]);
$("#form").show();
infowindow.setContent(marker.html);
infowindow.open(map, marker);
}
})(marker, i));
}
}

function saveData() {
var confirmed = document.getElementById('confirmed').checked ? 1 : 0;
var id = document.getElementById('id').value;
var url = 'locations_model.php?confirm_location&id=' + id + '&confirmed=' + confirmed;
downloadUrl(url, function(data, responseCode) {
if (responseCode === 200 && data.length > 1) {
infowindow.close();
window.location.reload(true);
}else{
infowindow.setContent("<div style='color: purple; font-size: 25px;'>Inserting Errors</div>");
}
});
}


function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;

request.onreadystatechange = function() {
if (request.readyState == 4) {
callback(request.responseText, request.status);
}
};

request.open('GET', url, true);
request.send(null);
}




<div style="display: none" id="form">
<table class="map1">
<tr>
<input name="id" type='hidden' id='id'/>
<td><a>Description:</a></td>
<td><textarea disabled id='description' placeholder='Description'></textarea></td>
</tr>

<tr>

<td><a>Image:</a></td>
<td><input type="image" disabled id='image' alt="" /></td>
</tr>
<tr>
<td><b>Confirm Location ?:</b></td>
<td><input id='confirmed' type='checkbox' name='confirmed'></td>
</tr>

<tr><td></td><td><input type='button' value='Save' onclick='saveData()'/></td></tr>
</table>







The image is getting by as an user input. the input image is successful recorded in the database. but it not visible in the info window







javascript php html mysql google-maps






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 at 17:13









Akash Manujaya

42




42












  • just as an aside, you realise your AJAX code will only ever work in Internet Explorer?
    – ADyson
    Nov 20 at 17:14


















  • just as an aside, you realise your AJAX code will only ever work in Internet Explorer?
    – ADyson
    Nov 20 at 17:14
















just as an aside, you realise your AJAX code will only ever work in Internet Explorer?
– ADyson
Nov 20 at 17:14




just as an aside, you realise your AJAX code will only ever work in Internet Explorer?
– ADyson
Nov 20 at 17:14

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398151%2fhow-to-get-an-image-from-the-database-and-show-that-image-in-google-map-info-win%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53398151%2fhow-to-get-an-image-from-the-database-and-show-that-image-in-google-map-info-win%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

Refactoring coordinates for Minecraft Pi buildings written in Python