I have an Array like below in PHP
array(
(int) 0 => array(
'id' => '1',
'name' => 'Mink7',
'about' => 'Creative Design agency',
'logo' => null,
'lat' => '13.004870000000',
'lng' => '77.576686084656'
),
(int) 1 => array(
'id' => '2',
'name' => 'Bakasura',
'about' => 'Live 2 Eat',
'logo' => null,
'lat' => '13.005643569006',
'lng' => '77.577485382942'
)
)
What have i done. I load the Function in the Header and have written the following in the body tag.
<script type="text/javascript">
$(document).ready(function(){
var startups = <?php echo json_encode($startups); ?>;
$.each(startups, function(key, val) {
markMe(val.lat, val.lng, val.name, val.description, val.logo);
});
});
</script>
I am getting the following error
markMe is not defined
markMe(val.lat, val.lng, val.name, val.description, val.logo);
Javascript File that is attached to HEAD.
// 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>'
}
});
function markMe(lat, lng, name, description, logo){
map.addMarker({
lat: lat,
lng: lng,
title: name,
icon: "http://i.imgur.com/3YJ8z.png",
infoWindow: {
content: description
}
});
}
});