Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
google mapでアイコン出すサンプル
$(function () {
var gmap = $('#gmap');
if (!gmap.length) return;
$.getJSON(gmap.find(':hidden').val(), function (data) {
if (!GBrowserIsCompatible()) return;
var map = new GMap2(gmap.get(0));
map.addControl(new GMapTypeControl());
map.addControl(new GLargeMapControl());
var bounds = new GLatLngBounds();
var markers = [];
$.each(data.markers, function () {
var item = data.markers.shift();
var lat_lng = new GLatLng(item.lat, item.lng);
bounds.extend(lat_lng);
var marker = new GMarker(lat_lng);
marker.openInfoWindowHtml(item.info_window);
markers.push(marker);
});
map.setCenter(bounds.getCenter(), data.zoom || 13);
$.each(markers, function () {
map.addOverlay(this);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment