Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Helpers for Google Maps v3 in Rails - Using html 5, the google maps api v3 and the static maps api Supports unobtrusive maps in Rails 3 (and 2.3, but preferably 3) using the new google maps v3 api.
Installing bhm-google-maps is simple. To get started with a rails 3 app:
gem "bhm-google-maps"
rake bhm-google-maps:install
Some parts of bhm-google-maps may need to be configured - e.g. out of the box, it will append the google
maps js url to the page and the gmap.js from where it was called, as an example of changing this, we suggest
creating config/initializers/bhm_google_maps_config.rb
and configuring from there. e.g:
# t is the scope of the view / helpers.
# This will append it to a content_for section
# instead of directly in the page.
BHM::GoogleMaps.include_js_proc = proc do |t|
t.content_for :extra_head, t.javascript_include_tag(t.google_maps_url(false), "gmap.js")
end
For a fuller / more in depth reference, see configuration below.
If you're using bhm-google-maps with Barista, you can skip
the rake bhm-google-maps:install
task, it will register itself as a framework with the default
output directory.
Currently, bhm-google-maps is designed to show a single map w/ static fallback. To do this,
you use the draw_map_of
helper. You pass it an object you wish to plot, typically following the
convention that:
object.lat
and object.lng
return latitude / longitude respectivelyobject.to_s
returns the string representing the address / the addressOf course, this can be changed via other conventions. For this example, we'll use the following class demo:
class Location
attr_accessor :address, :lat, :lng
def initialize(address, lat, lng)
@address = address
@lat = lat
@lng = lng
end
def to_s; address.to_s; end
end
Then, in your view, you could simple call:
<%= draw_map_of Location.new("My House", 12.345, 56.789) %>
Optionally, draw_map_of
accepts a hash of options for:
:static_map_html
- options to pass to the image_tag for the static map.:static_map
- options to pass to the BHM::GoogleMaps::StaticMap constructor. These include :type
, :width
and :height
:marker
- options to pass to the google.maps.Marker
in js.You also get the following helpers:
using_gmaps_js?
- whether or not the embed method has been calleduse_gmaps_js
- calls your embed method for the js - see configuration.google_maps_url(sensor = false)
- returns the url for the google maps api v3.static_map_of_addresses(addresses)
- returns an image tag for an array of addresses.static_map_of_address(address)
- returns an image tag for a given addressFor configuration purposes, there are a set of options on BHM::GoogleMaps
. You can
set them via BHM::GoogleMaps.option_name = value
container_class
- the map class for the container div, defaults to gmap. If changed, you must update the js.static_map_class
- the class of the container div, removed via js when made dynamic.include_js_proc
- how to embed js in the page (e.g. using content_for), defaults to using concat. Is called as a proc w/ the template passed as the only argument.address_to_s_proc
- passed an address, converts it to a string (defaults to to_s)address_to_lat_lng_proc
- passed an address, returns an array w/ lat and lng.Ideally these options should be set in an initializer.
Copyright (c) 2010 Youth Tree. See LICENSE for details.
FAQs
Unknown package
We found that bhm-google-maps demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.