Skip to content

Commit

Permalink
[fix] Can use addr attribute when type is notuse.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomoka Baba committed Apr 22, 2015
1 parent 46c81fa commit cd287fd
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 27 deletions.
45 changes: 32 additions & 13 deletions coffee/notusepost-map.coffee
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
initialize = ->
jQuery(document).find('[id^=map_canvas]').each ->
postInfo = window['kodamaps_posts_'+jQuery(@).attr('id').replace('map_canvas_','')]
initLat = if postInfo.centerLat? then postInfo.centerLat else 31.773827
initLng = if postInfo.centerLng? then postInfo.centerLng else 130.7518837
initLat = if postInfo.centerLat? and postInfo.centerLat isnt '' then parseFloat postInfo.centerLat,10 else 0
initLng = if postInfo.centerLng? and postInfo.centerLng isnt '' then parseFloat postInfo.centerLng,10 else 0
initZoom = if postInfo.zoom? and postInfo.zoom isnt '' then parseInt postInfo.zoom,10 else 10
address = if postInfo.centerAddr? and postInfo.centerAddr isnt '' then postInfo.centerAddr else ''

opt =
zoom: initZoom
center: new google.maps.LatLng initLat,initLng
mapTypeid: google.maps.MapTypeId.ROADMAP
if address isnt ''
_this = @
geocoder = new google.maps.Geocoder()
geocoder.geocode 'address': address,
(results,status) ->
if status is google.maps.GeocoderStatus.OK
initLat = results[0].geometry.location.k
initLng = results[0].geometry.location.D
opt =
zoom: initZoom
center: new google.maps.LatLng initLat,initLng
mapTypeid: google.maps.MapTypeId.ROADMAP
map = new google.maps.Map _this,opt
marker = new google.maps.Marker
position: new google.maps.LatLng initLat,initLng
map: map
map.panTo new google.maps.LatLng initLat,initLng
else
opt =
zoom: initZoom
center: new google.maps.LatLng initLat,initLng
mapTypeid: google.maps.MapTypeId.ROADMAP
map = new google.maps.Map @,opt
marker = new google.maps.Marker
position: new google.maps.LatLng initLat,initLng
map: map
map.panTo new google.maps.LatLng initLat,initLng

map = new google.maps.Map @,opt
marker = new google.maps.Marker
position: new google.maps.LatLng initLat,initLng
map: map
map.panTo new google.maps.LatLng initLat,initLng
return
return
return #each
return #initialize

window.onload = initialize
54 changes: 40 additions & 14 deletions js/notusepost-map.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cd287fd

Please sign in to comment.