Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomoka Baba committed Mar 30, 2015
0 parents commit 539c8c5
Show file tree
Hide file tree
Showing 6 changed files with 483 additions and 0 deletions.
68 changes: 68 additions & 0 deletions js/admin-map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
(function() {
var map, marker;
function initialize() {
var initLat = jQuery('#kodamaps-txt-input-lat').val() || 0;
var initLng = jQuery('#kodamaps-txt-input-lng').val() || 0;
var initZoom = (initLat || initLng) ? 16 : 0;
var mapOptions = {
zoom: initZoom,
center: new google.maps.LatLng(initLat, initLng),
};
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);

var latLng = new google.maps.LatLng(initLat, initLng);
marker = new google.maps.Marker({
position: latLng,
map: map
});

jQuery('#kodamaps-txt-input-address, #kodamaps-txt-input-lat, #kodamaps-txt-input-lng').change(function() {
var geocoder = new google.maps.Geocoder();
if (this.id === 'kodamaps-txt-input-address') {
var address = jQuery('#kodamaps-txt-input-address').val();
geocoder.geocode(
{
'address': address
},
function (results, status) {
if (status === google.maps.GeocoderStatus.OK) {
var latLng = new google.maps.LatLng(results[0].geometry.location.k, results[0].geometry.location.D);
marker.position = latLng;
marker.setMap(map);
map.panTo(new google.maps.LatLng(marker.getPosition().k, marker.getPosition().D));
map.setZoom(16);
jQuery('#kodamaps-txt-input-lat').val(marker.getPosition().k);
jQuery('#kodamaps-txt-input-lng').val(marker.getPosition().D);
jQuery('.kodamaps-postdata-address').val(address);
jQuery('.kodamaps-postdata-lat').val(marker.getPosition().k);
jQuery('.kodamaps-postdata-lng').val(marker.getPosition().D);
}
}
);
} else {
var latLng = new google.maps.LatLng(jQuery('#kodamaps-txt-input-lat').val(), jQuery('#kodamaps-txt-input-lng').val());
geocoder.geocode(
{
'latLng': latLng
},
function (results, status) {
if (status === google.maps.GeocoderStatus.OK) {
var address = results[0].formatted_address;
marker.position = latLng;
marker.setMap(map);
map.panTo(new google.maps.LatLng(marker.getPosition().k, marker.getPosition().D));
map.setZoom(16);
jQuery('#kodamaps-txt-input-address').val(address);
jQuery('#kodamaps-txt-input-lat').val(marker.getPosition().k);
jQuery('#kodamaps-txt-input-lng').val(marker.getPosition().D);
jQuery('.kodamaps-postdata-address').val(address);
jQuery('.kodamaps-postdata-lat').val(marker.getPosition().k);
jQuery('.kodamaps-postdata-lng').val(marker.getPosition().D);
}
}
);
}
});
}
window.onload = initialize;
}).call(this);
59 changes: 59 additions & 0 deletions js/allpost-map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
(function() {
var map;
function initialize() {
var initLat = 0;
var initLng = 0;
initLat = (typeof kodamaps_posts !== 'undefined') && kodamaps_posts.centerLat !== '' ? parseFloat(kodamaps_posts.centerLat, 10) : initLat;
initLng = (typeof kodamaps_posts !== 'undefined') && kodamaps_posts.centerLng !== '' ? parseFloat(kodamaps_posts.centerLng, 10) : initLng;
var initZoom = (typeof kodamaps_posts !== 'undefined') && kodamaps_posts.zoom !== '' ? parseInt(kodamaps_posts.zoom,10) : 10;
var address = (typeof kodamaps_posts !== 'undefined') && kodamaps_posts.centerAddr !== '' ? kodamaps_posts.centerAddr : '';
if (address !== '') {
var geocoder = new google.maps.Geocoder();
geocoder.geocode(
{
'address': address
},
function (results, status) {
if (status === google.maps.GeocoderStatus.OK) {
initLat = results[0].geometry.location.k;
initLng = results[0].geometry.location.D;
var mapOptions = {
zoom: initZoom,
center: new google.maps.LatLng(initLat, initLng),
mapTypeid: google.maps.MapTypeId.ROADMAP
};
if(document.getElementById("map_canvas")) {
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
}
kodamaps_posts.postInfo.forEach(function(post) {
var markerOption = {
position: new google.maps.LatLng(post.lat, post.lng),
map: map
};
if (post.marker) { markerOption.icon = post.marker; }
var marker = new google.maps.Marker(markerOption);
});
}
}
);
} else {
var mapOptions = {
zoom: initZoom,
center: new google.maps.LatLng(initLat, initLng),
mapTypeid: google.maps.MapTypeId.ROADMAP
};
if(document.getElementById("map_canvas")) {
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
}
kodamaps_posts.postInfo.forEach(function(post) {
var markerOption = {
position: new google.maps.LatLng(post.lat, post.lng),
map: map
};
if (post.marker) { markerOption.icon = post.marker; }
var marker = new google.maps.Marker(markerOption);
});
}
}
window.onload = initialize;
}).call(this);
23 changes: 23 additions & 0 deletions js/post-map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(function() {
var map;
function initialize() {
var initLat = (typeof kodamaps_post !== 'undefined') ? kodamaps_post.lat : 31.773827;
var initLng = (typeof kodamaps_post !== 'undefined') ? kodamaps_post.lng : 130.7518837;
var initZoom = (typeof kodamaps_post !== 'undefined') && kodamaps_post.zoom !== '' ? parseInt(kodamaps_post.zoom,10) : 10;
var mapOptions = {
zoom: initZoom,
center: new google.maps.LatLng(initLat, initLng),
mapTypeid: google.maps.MapTypeId.ROADMAP
};
if(document.getElementById("map_canvas")) {
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(kodamaps_post.lat, kodamaps_post.lng),
map: map,
icon: kodamaps_post.marker
});
map.panTo(new google.maps.LatLng(initLat, initLng));
}
}
window.onload = initialize;
}).call(this);
Loading

0 comments on commit 539c8c5

Please sign in to comment.